I’m wondering why this won’t work:
$oClass = get_called_class();
$sConstValue = $oClass::sConstName;
Where e.g. $oClass can be an instance of a class User and sConstName contains a value. I’m getting PHP’s native error Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in...
This code works on another machine. The difference is the version in PHP. My machine is running 5.2.17 and the other machine is running 5.3.6.
Is the error because of the PHP version? And if so, is there a workaround for my version of PHP? Atm I can’t update the version but I need this to work. It’s a piece of code helping/(going to help) me to dynamically generate models from database-tables.
This was not supported pre-PHP 5.3, as stated in the documentation:
A work around for your version of PHP would be to use the
constant()function: