Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有什么区别:
$this->$a和$this->b
$this->$a
$this->b
在我的课堂上,我有这个:
class someClass{ public $a; function aFunction(){ $this->a = 5; $this->$b = 7; } }
在$this->$b
$this->$b
有很多不同:
$this->a指$a您的班级的财产
$this->a
$a
$this->$b另一方面,通过名称来引用属性,该名称$b作为字符串存储在变量中:
$b
$b = "a"; $this->$b equals $this->a $b = "hello" $this->$b equals $this->hello