3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php 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 Deprecated: Non-static method foo::testTwo() should not be called statically in /in/5D2m2 on line 33 string(3) "foo" Deprecated: Non-static method foo::testTwo() should not be called statically in /in/5D2m2 on line 34 string(3) "bar" in a class string(3) "foo" string(3) "bar" in a class without static declaration Deprecated: Non-static method foo::testTwo() should not be called statically in /in/5D2m2 on line 23 string(3) "foo" Deprecated: Non-static method foo::testTwo() should not be called statically in /in/5D2m2 on line 24 string(3) "bar"
Output for hhvm-3.10.0 - 3.12.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.6.0 - 5.6.28
basic string(3) "foo" string(3) "bar" basic without static declaration Strict Standards: Non-static method foo::testTwo() should not be called statically in /in/5D2m2 on line 33 string(3) "foo" Strict Standards: Non-static method foo::testTwo() should not be called statically in /in/5D2m2 on line 34 string(3) "bar" in a class string(3) "foo" string(3) "bar" in a class without static declaration Deprecated: Non-static method foo::testTwo() should not be called statically, assuming $this from incompatible context in /in/5D2m2 on line 23 string(3) "abc" Deprecated: Non-static method foo::testTwo() should not be called statically, assuming $this from incompatible context in /in/5D2m2 on line 24 string(3) "abc"
Output for 5.3.0 - 5.5.35
basic string(3) "foo" string(3) "bar" basic without static declaration Strict Standards: Non-static method foo::testTwo() should not be called statically in /in/5D2m2 on line 33 string(3) "foo" Strict Standards: Non-static method foo::testTwo() should not be called statically in /in/5D2m2 on line 34 string(3) "bar" in a class string(3) "foo" string(3) "bar" in a class without static declaration Strict Standards: Non-static method foo::testTwo() should not be called statically, assuming $this from incompatible context in /in/5D2m2 on line 23 string(3) "abc" Strict Standards: Non-static method foo::testTwo() should not be called statically, assuming $this from incompatible context in /in/5D2m2 on line 24 string(3) "abc"
Output for 5.0.0 - 5.2.17
basic Fatal error: Call to undefined function get_called_class() in /in/5D2m2 on line 5
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/5D2m2 on line 4
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/5D2m2 on line 4
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/5D2m2 on line 4
Process exited with code 255.