3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $cb; public function __construct() { $this->cb = function() { $foo = "this"; var_dump($$foo, get_class()); }; } } ((new A)->cb)();
Output for 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Deprecated: Calling get_class() without arguments is deprecated in /in/odFHU on line 9 object(A)#1 (1) { ["cb"]=> object(Closure)#2 (4) { ["name"]=> string(28) "{closure:A::__construct():7}" ["file"]=> string(9) "/in/odFHU" ["line"]=> int(7) ["this"]=> *RECURSION* } } string(1) "A"
Output for 8.3.0 - 8.3.30
Deprecated: Calling get_class() without arguments is deprecated in /in/odFHU on line 9 object(A)#1 (1) { ["cb"]=> object(Closure)#2 (1) { ["this"]=> *RECURSION* } } string(1) "A"
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30
object(A)#1 (1) { ["cb"]=> object(Closure)#2 (1) { ["this"]=> *RECURSION* } } string(1) "A"
Output for 7.0.0 - 7.0.33
Notice: Undefined variable: this in /in/odFHU on line 9 NULL string(1) "A"
Output for 5.6.0 - 5.6.40
Parse error: syntax error, unexpected '(' in /in/odFHU on line 14
Process exited with code 255.

preferences:
69.24 ms | 2001 KiB | 4 Q