I am getting the following error!
Fatal error: Constant expression contains invalid operations in >/PATH/initClass.php on line 5
For the code:
<?php
Class init
{
public const THEME = "aman/dev/frontend/";
private $root = dirname(__dir__)."/aman/dev/fontend/";
public function getFile($name,$value)
{
list(
$title
) = $value;
}
}
?>
I can't seem to figure out what's is happening.
Help would be appreciated.
__dir__
" in the expression for a private variable. I haven't dived deep into this, but I expect that since it can't know__dir__
until runtime, that it doesn't want to use it that way. Try setting the private variable to null, then set it with the full expression in a constructor. – UncaAlby