3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Non-static method Class1::foo() cannot be called statically in /in/8F5Pj:26 Stack trace: #0 /in/8F5Pj(33): Class2->bar() #1 {main} thrown in /in/8F5Pj on line 26
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33
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 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 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.0.5, 5.1.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.3.11, 4.4.0 - 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

preferences:
225.98 ms | 401 KiB | 356 Q