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() { return $this->stage.''; } } $array['test'] = function ($i) {return new Test($i);}; echo $array['test']('2'); echo $array['test'];
based on K38fo
Output for 7.1.0 - 7.2.6
2 Recoverable fatal error: Object of class Closure could not be converted to string in /in/tRu03 on line 20
Process exited with code 255.
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.20
2 Catchable fatal error: Object of class Closure could not be converted to string in /in/tRu03 on line 20
Process exited with code 255.
Output for hhvm-3.15.4
2 Fatal error: Uncaught Error: Object of class Closure$__toString;226548272$75ed45df086fdc802d20c2c71bc5021f$ could not be converted to string in /in/tRu03:20 Stack trace: #0 {main}
Process exited with code 255.