3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class User { public $username; public $binders; function __construct($username, $binders) { $this->username = $username; $this->binders = $binders; } } class Binder { public $name; public $contents; function __construct($name, $contents = array()) { $this->name = $name; $this->contents = $contents; } } class Card { public $id; public $quantity; function __construct($id, $quantity = 0) { $this->id = $id; $this->quantity = $quantity; } } $users = array ( 'TestName' => new User ( 'TestName', array ( 'BinderName1' => new Binder ( 'BinderName1', array ( 'CardID_1' => new Card('1', '20'), 'CardID_3' => new Card('3', '10'), ) ), 'BinderName2' => new Binder ( 'BinderName2', array ( 'CardID_1' => new Card('1', '7') ) ) ) ) ); print_r($users); $users['TestName']->binders['BinderName1']->contents['CardID_1']->quantity = 5; print_r($users);
Output for 5.0.0 - 7.2.11
Array ( [TestName] => User Object ( [username] => TestName [binders] => Array ( [BinderName1] => Binder Object ( [name] => BinderName1 [contents] => Array ( [CardID_1] => Card Object ( [id] => 1 [quantity] => 20 ) [CardID_3] => Card Object ( [id] => 3 [quantity] => 10 ) ) ) [BinderName2] => Binder Object ( [name] => BinderName2 [contents] => Array ( [CardID_1] => Card Object ( [id] => 1 [quantity] => 7 ) ) ) ) ) ) Array ( [TestName] => User Object ( [username] => TestName [binders] => Array ( [BinderName1] => Binder Object ( [name] => BinderName1 [contents] => Array ( [CardID_1] => Card Object ( [id] => 1 [quantity] => 5 ) [CardID_3] => Card Object ( [id] => 3 [quantity] => 10 ) ) ) [BinderName2] => Binder Object ( [name] => BinderName2 [contents] => Array ( [CardID_1] => Card Object ( [id] => 1 [quantity] => 7 ) ) ) ) ) )
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/p28ma on line 5
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/p28ma on line 5
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/p28ma on line 5
Process exited with code 255.