<?php
class A
{
public static function who()
{
var_dump(get_called_class());
}
}
class B extends A
{
public static function who()
{
parent::who();
}
}
B::who();
call_user_func(array('A', 'who'));
call_user_func(array('B', 'parent::who'));
$method = array('B', 'parent::who');
$method();
?>
string(1) "B"
string(1) "A"
Deprecated: Callables of the form ["B", "parent::who"] are deprecated in /in/vbuVd on line 19
string(1) "A"
Fatal error: Uncaught Error: Call to undefined method B::parent::who() in /in/vbuVd:22
Stack trace:
#0 {main}
thrown in /in/vbuVd on line 22
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
string(1) "B"
string(1) "A"
Deprecated: Callables of the form ["B", "parent::who"] are deprecated in /in/vbuVd on line 19
string(1) "A"
Fatal error: Uncaught Error: Call to undefined method B::parent::who() in /in/vbuVd:22
Stack trace:
#0 {main}
thrown in /in/vbuVd on line 22
Process exited with code 255.
string(1) "B"
string(1) "A"
string(1) "A"
Fatal error: Uncaught Error: Call to undefined method B::parent::who() in /in/vbuVd:22
Stack trace:
#0 {main}
thrown in /in/vbuVd on line 22
Process exited with code 255.
Output for 8.0.0 - 8.0.9
string(1) "B"
string(1) "A"
Fatal error: Uncaught Error: get_called_class() must be called from within a class in /in/vbuVd:7
Stack trace:
#0 /in/vbuVd(19): A::who()
#1 {main}
thrown in /in/vbuVd on line 7
Process exited with code 255.
string(1) "B"
string(1) "A"
bool(false)
Fatal error: Uncaught Error: Call to undefined method B::parent::who() in /in/vbuVd:22
Stack trace:
#0 {main}
thrown in /in/vbuVd on line 22
Process exited with code 255.
Fatal error: Call to undefined function get_called_class() in /in/vbuVd on line 7
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/vbuVd on line 5
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/vbuVd on line 5
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/vbuVd on line 5
Process exited with code 255.