3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class A { var $aa = 1; } class B { var $objA; function setA(A $objA) { $this->objA = $objA; } } $objA = new A; $objB = new B(); $objB->setA($objA); $objB->objA->aa = 666; var_dump($objA, $objB);
Output for 5.1.3 - 7.1.0
object(A)#1 (1) { ["aa"]=> int(666) } object(B)#2 (1) { ["objA"]=> object(A)#1 (1) { ["aa"]=> int(666) } }
Output for 5.0.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/WKhc4 on line 3 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/WKhc4 on line 7 object(A)#1 (1) { ["aa"]=> int(666) } object(B)#2 (1) { ["objA"]=> object(A)#1 (1) { ["aa"]=> int(666) } }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/WKhc4 on line 9
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 ')' in /in/WKhc4 on line 9
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/WKhc4 on line 9
Process exited with code 255.