3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public $x; } $x = new Foo(); $x->x = $x; // comment this line out $y = new WeakRef($x); unset($x); var_dump($y->get()); gc_collect_cycles(); var_dump($y->get());
Output for 7.1.0 - 7.2.6
Fatal error: Uncaught Error: Class 'WeakRef' not found in /in/o2kk2:9 Stack trace: #0 {main} thrown in /in/o2kk2 on line 9
Process exited with code 255.
Output for hhvm-3.18.5 - 3.22.0
object(Foo)#1 (1) { ["x"]=> *RECURSION* } object(Foo)#1 (1) { ["x"]=> *RECURSION* }
Output for 5.6.0 - 5.6.30
Fatal error: Class 'WeakRef' not found in /in/o2kk2 on line 9
Process exited with code 255.