3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Y { private $x; function __construct(X $x) { $this->x = $x; } } class X { private $i; private $y; function __construct($i) { $this->i = $i; $this->y = new Y($this); } function __destruct() { echo "I'm done {$this->i} !\n"; } } function make_x($i) { new X($i); } for ($i = 0; $i < 10; $i++) { echo "Making X $i\n"; make_x($i); }
based on 2E9hE
Output for 5.0.0 - 7.2.0
Making X 0 Making X 1 Making X 2 Making X 3 Making X 4 Making X 5 Making X 6 Making X 7 Making X 8 Making X 9 I'm done 0 ! I'm done 1 ! I'm done 2 ! I'm done 3 ! I'm done 4 ! I'm done 5 ! I'm done 6 ! I'm done 7 ! I'm done 8 ! I'm done 9 !
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/013JD on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/013JD on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/013JD on line 4
Process exited with code 255.