3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Config { //declare variables private $kmailtext; function __construct() { $this->kmailtext = "Mail ons"; } public function __get($name) { return $this->$name; } } class someOtherClass extends Config { private $kmailsubject; function __construct() { $this->$kmailsubject = "Subject"; parent::__construct(); } public function someOtherFunction() { return $this->kmailsubject; } public function __get($name) { if (isset($this->$name)) return $this->$name; return parent::__get($name); } } $config = new someOtherClass(); echo $config->someOtherFunction(), PHP_EOL; echo $config->someFunction();
based on 6tXv2
Output for 7.1.0 - 7.2.0
Notice: Undefined variable: kmailsubject in /in/plNvZ on line 23 Fatal error: Uncaught Error: Call to undefined method someOtherClass::someFunction() in /in/plNvZ:42 Stack trace: #0 {main} thrown in /in/plNvZ on line 42
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Notice: Undefined variable: kmailsubject in /in/plNvZ on line 23 Fatal error: Uncaught Error: Cannot access empty property in /in/plNvZ:23 Stack trace: #0 /in/plNvZ(40): someOtherClass->__construct() #1 {main} thrown in /in/plNvZ on line 23
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Notice: Undefined variable: kmailsubject in /in/plNvZ on line 23 Fatal error: Cannot access empty property in /in/plNvZ on line 23
Process exited with code 255.