php 如果在类中定义变量,在类的方法中调用时应该加上$this-> .
class ClassName { private $a = 333; function __construct() { $this->a = 2222; } public function bbb($value=‘‘) { echo $this->a; } } $b = new className(); echo $b->bbb();
时间: 2024-11-05 19:30:31
php 如果在类中定义变量,在类的方法中调用时应该加上$this-> .
class ClassName { private $a = 333; function __construct() { $this->a = 2222; } public function bbb($value=‘‘) { echo $this->a; } } $b = new className(); echo $b->bbb();