0
我的印象是,下面的概念可以工作,但$ foo的新值不會在函數之間傳遞。什麼是正確的方法來做到這一點?php - 傳遞類之間函數變量的更新值
class doSomething
{
public $foo = "good";
public function changeFooAgain()
{
$this->foo = "best";
}
public function changeFoo()
{
$this->foo = "better";
}
public function getFoo()
{
$this->changeFoo();
$this->changeFooAgain();
return $this->foo;
}
}
$foo = new doSomething;
print $foo->getFoo();