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']('test'); echo $array['test'](2);
based on HjOkb
Output for 7.1.0 - 7.3.0rc3
test Recoverable fatal error: Method Test::__toString() must return a string value in /in/UXRLm on line 19
Process exited with code 255.
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.20
test Catchable fatal error: Method Test::__toString() must return a string value in /in/UXRLm on line 19
Process exited with code 255.
Output for hhvm-3.15.4
test Fatal error: Uncaught Error: Method Test::__toString() must return a string value in /in/UXRLm:19 Stack trace: #0 {main}
Process exited with code 255.