1.简单实验代码区域
<?php class test{ public static $status="very good"; public $name='雷锋'; public function myinfo(){ echo '我叫:'.$this->name.'我的状态:'.self::$status='不知道'; } public function myinfo1(){ echo '我叫:'.$this->name='123'.'我的状态:'.self::$status='第二次赋值'; } } $test=new test(); $test->myinfo(); echo '<br>'; echo '<br>'; $test->myinfo1(); echo '<br>'; echo '<br>'; echo $test->name; echo '<br>'; echo '<br>'; echo test::$status; echo '<br>'; echo '<br>'; $test1=new test();//第二次实例化 $test1->myinfo(); echo '<br>'; echo '<br>'; $test1->myinfo1(); echo '<br>'; echo '<br>'; echo $test1->name; echo '<br>'; echo '<br>'; echo $test1::$status;
2.显示结果
来源:https://www.cnblogs.com/yaoliuyang/p/12563966.html