3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test { public $stage; public function __construct($stage) { $this->stage = $stage; } public function __toString() { echo $this->stage.''; } } $array['test'] = function ($i) {return new Test($i);}; echo $array['test']('2');
based on nBsvS
Output for 7.1.0 - 7.2.6
2 Recoverable fatal error: Method Test::__toString() must return a string value in /in/nmTuk on line 19
Process exited with code 255.
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.20
2 Catchable fatal error: Method Test::__toString() must return a string value in /in/nmTuk on line 19
Process exited with code 255.
Output for hhvm-3.15.4
2 Fatal error: Uncaught Error: Method Test::__toString() must return a string value in /in/nmTuk:19 Stack trace: #0 {main}
Process exited with code 255.