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