3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class B { public $var; public function __construct($var) { $this->var = $var; } } class A { public $var; public function __construct(B $var) { $this->var = $var; } } $b = new B('test'); $a = new A($b); $b->var = 'test2'; echo $b->var; echo $a->var;
based on 06Ys2
Output for 7.1.0 - 7.2.0
test2 Recoverable fatal error: Object of class B could not be converted to string in /in/icqg0 on line 21
Process exited with code 255.
Output for 5.5.0 - 7.0.20
test2 Catchable fatal error: Object of class B could not be converted to string in /in/icqg0 on line 21
Process exited with code 255.