-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1129.php
44 lines (44 loc) · 912 Bytes
/
1129.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
class Person {
private $name;
private $age;
private $sex;
function __construct($name="wu",$age=26,$sex="women"){
$this->name=$name;
$this->age=$age;
$this->sex=$sex;
echo "haha<br>";
}
private function __get($proName){
echo "__get";
}
private function __set($proName,$proValue){ //直接设置私有成员属性值自动调用的方法!
$this->$proName==name;
$this->$proValue==age;
echo "wo name is{$this->name}<br>";
echo "i'm {$this->age} old<br>";
}
function say(){
echo "my name is:{$this->name}<br>";
echo "i'm {$this->age} old !<br>";
}
function work(){
echo $this->age;
$this->food();
}
private function food(){
echo $this->name;
}
}
/* $p = new Person("wudong",20);
$p1 =new Person("dong",22);
$p1->name="hiwud";
$p->say();
$p1->say();
$p->work();
echo $p->name;
echo $p1->name;
*/
$p->name="hi";
$p->say();
$p1->say();