<?php
$description = null;
class Base {
public static function describe() {
global $description;
if ($description === null) {
$description = "I am a " . get_called_class() . "\n";
}
return $description;
}
}
class Animal extends Base {
}
class Cat extends Animal {
public static function describe() {
return 'Miauw! ' . parent::describe();
}
}
class Dog extends Animal {
}
echo Cat::describe();
echo Dog::describe();
echo Animal::describe();
Fatal error: Call to undefined function get_called_class() in /in/0RlHh on line 10
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/0RlHh on line 6
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/0RlHh on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/0RlHh on line 6
Process exited with code 255.