3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $squad_ids = array("1","2"); $squads = array(); $squads_num = 0; class Squad { private $id; function __construct(){ $this->id = $id; } } foreach ($squad_ids as $squad_id){ $squads[$squads_num] = new Squad($squad_id); print_r($squads[$squads_num]); $squads_num++; } foreach ($squads as $squad){ print_r($squad); }
Output for 5.3.0 - 7.1.0
Notice: Undefined variable: id in /in/3gtS9 on line 9 Squad Object ( [id:Squad:private] => ) Notice: Undefined variable: id in /in/3gtS9 on line 9 Squad Object ( [id:Squad:private] => ) Squad Object ( [id:Squad:private] => ) Squad Object ( [id:Squad:private] => )
Output for 5.0.4 - 5.2.17
Notice: Undefined variable: id in /in/3gtS9 on line 9 Squad Object ( [id:private] => ) Notice: Undefined variable: id in /in/3gtS9 on line 9 Squad Object ( [id:private] => ) Squad Object ( [id:private] => ) Squad Object ( [id:private] => )
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: id in /in/3gtS9 on line 9 Squad Object ( [id:private] => ) Notice: Undefined variable: id in /in/3gtS9 on line 9 Squad Object ( [id:private] => ) Squad Object ( [id:private] => ) Squad Object ( [id:private] => )
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/3gtS9 on line 7
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/3gtS9 on line 7
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/3gtS9 on line 7
Process exited with code 255.