3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(E_ERROR | E_WARNING | E_PARSE); class Class1 { var $testVar = 5; function foo(){ echo $this->foo2(); } function foo2(){ } } class Class2 { function __construct(){ $this->class1 = new Class1(); } function bar(){ //This doesn't report an error because error level 'strict' is disabled. Class1::foo(); } } $class2 = new Class2(); $class2->bar(); ?>
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Using $this when not in object context in /in/8F5Pj:10 Stack trace: #0 /in/8F5Pj(26): Class1::foo() #1 /in/8F5Pj(33): Class2->bar() #2 {main} thrown in /in/8F5Pj on line 10
Process exited with code 255.
Output for hhvm-3.12.0
Fatal error: Uncaught Error: $this is null in /in/8F5Pj:10 Stack trace: #0 /in/8F5Pj(26): Class1::foo() #1 /in/8F5Pj(33): Class2->bar() #2 {main}
Process exited with code 255.
Output for hhvm-3.10.0
Fatal error: $this is null in /in/8F5Pj on line 10
Process exited with code 255.
Output for 5.1.3 - 5.6.28
Fatal error: Call to undefined method Class2::foo2() in /in/8F5Pj on line 10
Process exited with code 255.
Output for 5.0.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/8F5Pj on line 7 Fatal error: Call to undefined method Class2::foo2() in /in/8F5Pj on line 10
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined method: class2->foo2() in /in/8F5Pj on line 10
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: foo2() in /in/8F5Pj on line 10
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: foo2() in /in/8F5Pj on line 10