3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class a { public $pub = 'public in a'; function pub() { echo "Entering a::pub\n"; var_dump($this->pub); echo "Leaving a::pub\n"; } } class x { public $pub = 'public in x'; function pub() { echo "Entering x::pub\n"; a::pub(); echo "Leaving x::pub\n"; } } function main() { $a = new a; $x = new x; echo "Calling a->pub\n"; $a->pub(); echo "Calling x->pub\n"; $x->pub(); } echo "Calling main()\n"; main(); echo "Done\n";
based on HT5s9
Output for 7.0.0 - 7.1.0
Calling main() Calling a->pub Entering a::pub string(11) "public in a" Leaving a::pub Calling x->pub Entering x::pub Deprecated: Non-static method a::pub() should not be called statically in /in/v9UnE on line 16 Entering a::pub Fatal error: Uncaught Error: Using $this when not in object context in /in/v9UnE:7 Stack trace: #0 /in/v9UnE(16): a::pub() #1 /in/v9UnE(28): x->pub() #2 /in/v9UnE(32): main() #3 {main} thrown in /in/v9UnE on line 7
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Calling main() Calling a->pub Entering a::pub string(11) "public in a" Leaving a::pub Calling x->pub Entering x::pub Deprecated: Non-static method a::pub() should not be called statically, assuming $this from incompatible context in /in/v9UnE on line 16 Entering a::pub string(11) "public in x" Leaving a::pub Leaving x::pub Done
Output for 5.1.3 - 5.5.35
Calling main() Calling a->pub Entering a::pub string(11) "public in a" Leaving a::pub Calling x->pub Entering x::pub Strict Standards: Non-static method a::pub() should not be called statically, assuming $this from incompatible context in /in/v9UnE on line 16 Entering a::pub string(11) "public in x" Leaving a::pub Leaving x::pub Done
Output for 5.0.0 - 5.1.2
Calling main() Calling a->pub Entering a::pub string(11) "public in a" Leaving a::pub Calling x->pub Entering x::pub Entering a::pub string(11) "public in x" Leaving a::pub Leaving x::pub Done
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/v9UnE 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_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/v9UnE 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/v9UnE on line 4
Process exited with code 255.