I know that you can assign a return value function to a variable and use it, for example:
function standardModel()
{
return "Higgs Boson";
}
$nextBigThing = standardModel();
echo $nextBigThing;
So will someone tell me why the following does not work? Or is it not yet implemented? Did I miss something?
class standardModel
{
private function nextBigThing()
{
return "Higgs Boson";
}
public $nextBigThing = $this->nextBigThing();
}
$standardModel = new standardModel;
echo $standardModel->nextBigThing;
I know that I could do this:
class standardModel
{
public function nextBigThing()
{
return "Higgs Boson";
}
}
$standardModel = new standardModel;
echo $standardModel->nextBigThing();
But in my project case, all the information stored in the class is predefined public vars, except one of them, which should calculate the value at runtime.
I want it to be consistent so that I or some other developer using this project does not remember that one value should be a function call, not a var call.
, , PHP-?
, . , "" . , . !