3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a { public $t = 3; public function call($fun) { $b = $fun($p); } } class b { public $t = 5; public function test() { a::call(function($this) {echo $this->t;}); } } b::test();
Output for 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 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: Cannot use $this as parameter in /in/gZ6Mf on line 12
Process exited with code 255.
Output for 7.0.0 - 7.0.6
Deprecated: Non-static method b::test() should not be called statically in /in/gZ6Mf on line 15 Deprecated: Non-static method a::call() should not be called statically in /in/gZ6Mf on line 12 Notice: Undefined variable: p in /in/gZ6Mf on line 6 Fatal error: Uncaught Error: Using $this when not in object context in /in/gZ6Mf:12 Stack trace: #0 /in/gZ6Mf(6): b::{closure}(NULL) #1 /in/gZ6Mf(12): a::call(Object(Closure)) #2 /in/gZ6Mf(15): b::test() #3 {main} thrown in /in/gZ6Mf on line 12
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Strict Standards: Non-static method b::test() should not be called statically in /in/gZ6Mf on line 15 Strict Standards: Non-static method a::call() should not be called statically in /in/gZ6Mf on line 12 Notice: Undefined variable: p in /in/gZ6Mf on line 6 Fatal error: Using $this when not in object context in /in/gZ6Mf on line 12
Process exited with code 255.

preferences:
162.93 ms | 402 KiB | 182 Q