I am trying to learn traits. I have used the example from PHP manual, but it does not work – why?
trait ezcReflectionReturnInfo {
function getReturnType() { /*1*/ }
function getReturnDescription() { /*2*/ }
}
class ezcReflectionMethod extends ReflectionMethod {
use ezcReflectionReturnInfo;
}
class ezcReflectionFunction extends ReflectionFunction {
use ezcReflectionReturnInfo;
}
I get the error:
Parse error: syntax error, unexpected T_STRING in /path/index.php on line 23
Check your PHP version.
do
echo PHP_VERSION_ID;From Traits:PHP Manual