3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test { private $x; private $y; public function __construct() { $this->x = 10; $this->y = function (){ return $this->getToutesLesCommandes();}; } public function __get($k) { return $this->$k; } public function getToutesLesCommandes() { //sleep(5); echo "Et 5 tres longues secondes plus tard..."; return array('commande1' => 123456, 'commande2' => 456789); } } $t = new Test(); //var_dump($t); echo $t->y; var_dump($t->y);
based on BXUVk
Output for 7.1.0 - 7.2.0
Recoverable fatal error: Object of class Closure could not be converted to string in /in/VQ57o on line 30
Process exited with code 255.
Output for 5.3.19 - 7.0.20
Catchable fatal error: Object of class Closure could not be converted to string in /in/VQ57o on line 30
Process exited with code 255.