时间:2021-07-01 10:21:17 帮助过:11人阅读
- class a {
- function __construct() {
- echo "a";
- }
- }
- class b extends a{
- function __construct(){
- echo "b";
- }
- private $x=100;
- public static function getx(){
- return $this->x;
- }
- }
- $x=new b();
- echo $x->getx();
结果是:
b100
“a”竟然没有输出,真不知到PHP5面向对象里类初始化的顺序。
http://www.bkjia.com/PHPjc/446437.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/446437.htmlTechArticle大家也许对 好了,先将代码贴出来 classa{ function__construct(){ echo"a"; } } classbextendsa{ function__construct(){ echo"b"; } private$ x = 100 ; publicstaticfunction...