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; echo $a;
Output for 7.1.0 - 7.2.0
Recoverable fatal error: Object of class B could not be converted to string in /in/06Ys2 on line 20
Process exited with code 255.
Output for 5.3.22 - 7.0.20
Catchable fatal error: Object of class B could not be converted to string in /in/06Ys2 on line 20
Process exited with code 255.