PHP 类
class a { public $a=0; public fucntion ax(){ $this->a='111'; } public fucntion bx(){ echo $this->a; }}
你的function写错了。。。。
实例化后按顺序执行 ax,bx 就有了
你要明白一点,ax/bx在类内是平行的,不是说你写在前面,后面的就有值
class a { public $a=0; public fucntion a(){ $this->a='111'; } public fucntion bx(){ echo $this->a; }}
class a { public $a=0; public function a(){ return $this->a='111'; } public function bx(){ echo $this->a(); }}$p = new a();$p->bx();