3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); class foo { static public function test() { var_dump(get_called_class()); } public function testTwo() { var_dump(get_called_class()); } } class bar extends foo { } class abc { function test() { foo::test(); bar::test(); } function testTwo() { foo::testTwo(); bar::testTwo(); } } echo "basic\n"; foo::test(); bar::test(); echo "basic without static declaration\n"; foo::testTwo(); bar::testTwo(); echo "in a class\n"; $abc = new abc(); $abc->test(); echo "in a class without static declaration\n"; $abc->testTwo();
Output for 7.0.0 - 7.1.0
basic string(3) "foo" string(3) "bar" basic without static declaration string(3) "foo" string(3) "bar" in a class string(3) "foo" string(3) "bar" in a class without static declaration string(3) "foo" string(3) "bar"
Output for 5.3.0 - 5.6.28
basic string(3) "foo" string(3) "bar" basic without static declaration string(3) "foo" string(3) "bar" in a class string(3) "foo" string(3) "bar" in a class without static declaration string(3) "abc" string(3) "abc"
Output for 5.0.0 - 5.2.17
basic Fatal error: Call to undefined function get_called_class() in /in/57N9u on line 7
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/57N9u on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STATIC, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/57N9u 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/57N9u on line 6
Process exited with code 255.