3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class FooException extends Exception { public function __toString() { return Exception::__toString(); } } class Foo { public $prop = 'bar'; public function nonStatic() { return $this->prop; } } class Bar { public function anotherNonStatic() { return Foo::nonStatic(); } } $a = new FooException(); var_dump($a->__toString()); $b = new Bar(); var_dump($b->anotherNonStatic());
Output for 7.0.0 - 7.1.0
string(51) "FooException in /in/m8VSh:22 Stack trace: #0 {main}" Deprecated: Non-static method Foo::nonStatic() should not be called statically in /in/m8VSh on line 19 Fatal error: Uncaught Error: Using $this when not in object context in /in/m8VSh:14 Stack trace: #0 /in/m8VSh(19): Foo::nonStatic() #1 /in/m8VSh(25): Bar->anotherNonStatic() #2 {main} thrown in /in/m8VSh on line 14
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
string(79) "exception 'FooException' with message '' in /in/m8VSh:22 Stack trace: #0 {main}" Fatal error: $this is null in /in/m8VSh on line 14
Process exited with code 255.
Output for 5.6.0 - 5.6.28
string(63) "exception 'FooException' in /in/m8VSh:22 Stack trace: #0 {main}" Deprecated: Non-static method Foo::nonStatic() should not be called statically, assuming $this from incompatible context in /in/m8VSh on line 19 Notice: Undefined property: Bar::$prop in /in/m8VSh on line 14 NULL
Output for 5.2.6 - 5.5.35
string(63) "exception 'FooException' in /in/m8VSh:22 Stack trace: #0 {main}" Strict Standards: Non-static method Foo::nonStatic() should not be called statically, assuming $this from incompatible context in /in/m8VSh on line 19 Notice: Undefined property: Bar::$prop in /in/m8VSh on line 14 NULL
Output for 5.1.3 - 5.2.5
string(63) "exception 'FooException' in /in/m8VSh:22 Stack trace: #0 {main}" Strict Standards: Non-static method Foo::nonStatic() should not be called statically, assuming $this from incompatible context in /in/m8VSh on line 19 Notice: Undefined property: Bar::$prop in /in/m8VSh on line 14 NULL
Output for 5.0.0 - 5.0.2, 5.0.5 - 5.1.2
string(63) "exception 'FooException' in /in/m8VSh:22 Stack trace: #0 {main}" Notice: Undefined property: Bar::$prop in /in/m8VSh on line 14 NULL
Output for 5.0.3 - 5.0.4
string(91) "exception 'FooException' in /in/m8VSh:22 Stack trace: #0 /in/m8VSh(22): unknown() #1 {main}" Notice: Undefined property: Bar::$prop in /in/m8VSh on line 14 NULL
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/m8VSh on line 5
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/m8VSh 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/m8VSh on line 5
Process exited with code 255.