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 getY() { 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); var_dump($t->getY()); var_dump($t->getY());
based on iZQF5
Output for 7.1.0 - 7.2.0
Notice: Undefined variable: k in /in/sTD4g on line 16 Notice: Undefined property: Test::$ in /in/sTD4g on line 16 NULL Notice: Undefined variable: k in /in/sTD4g on line 16 Notice: Undefined property: Test::$ in /in/sTD4g on line 16 NULL
Output for 7.0.0 - 7.0.20
Notice: Undefined variable: k in /in/sTD4g on line 16 Fatal error: Uncaught Error: Cannot access empty property in /in/sTD4g:16 Stack trace: #0 /in/sTD4g(30): Test->getY() #1 {main} thrown in /in/sTD4g on line 16
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Notice: Undefined variable: k in /in/sTD4g on line 16 Fatal error: Cannot access empty property in /in/sTD4g on line 16
Process exited with code 255.