3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class B { public $c=12; } class A { function __construct() { $this->va = function() { return new B; }; } } $o=new A; var_dump($o); var_dump(($o->va)());
based on G8NOf
Output for 7.0.0 - 7.2.0
object(A)#1 (1) { ["va"]=> object(Closure)#2 (1) { ["this"]=> *RECURSION* } } object(B)#3 (1) { ["c"]=> int(12) }
Output for 5.3.21 - 5.4.19, 5.4.21 - 5.6.28
Parse error: syntax error, unexpected '(' in /in/TBnrN on line 17
Process exited with code 255.
Output for 5.4.20

Process exited with code 137.