3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class X { private $i; function __construct($i) { $this->i = $i; } 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 PeVSE
Output for 5.0.0 - 7.2.0
Making X 0 I'm done 0 ! Making X 1 I'm done 1 ! Making X 2 I'm done 2 ! Making X 3 I'm done 3 ! Making X 4 I'm done 4 ! Making X 5 I'm done 5 ! Making X 6 I'm done 6 ! Making X 7 I'm done 7 ! Making X 8 I'm done 8 ! Making X 9 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/DgfAd 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/DgfAd 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/DgfAd on line 4
Process exited with code 255.