I’m very new to Php OOP and am getting stuck on one particular problem. I have trawled stackoverflow to try and find an answer, but can’t. I’ve spent over an hour on this one problem and am about ready to give up. I know a Php guru will see my issue straight away, so please tell me why this class won’t work.
<?php
class tester{
public $testproperty;
public function testfunction(){
$this->$testproperty = 'Nothing';
return $this->$testproperty;
}
}
$object = new tester();
echo $object->testfunction();
?>
1 Answer