我对 Php OOP 非常陌生,并且陷入了一个特定问题。我已经搜寻了stackoverflow以尝试找到答案,但不能。我在这个问题上花了一个多小时,准备放弃了。我知道 Php 大师会立即看到我的问题,所以请告诉我为什么这门课不起作用。
<?php
class tester{
public $testproperty;
public function testfunction(){
$this->$testproperty = 'Nothing';
return $this->$testproperty;
}
}
$object = new tester();
echo $object->testfunction();
?>