3v4l.org

run code in 300+ PHP versions simultaneously
<?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();
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined variable $kmailsubject in /in/plNvZ on line 23 Deprecated: Creation of dynamic property someOtherClass::$ is deprecated 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 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Warning: 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.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
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.3.32 - 7.3.33
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.33
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.5.0 - 5.5.38, 5.6.0 - 5.6.40
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.

preferences:
242.64 ms | 402 KiB | 329 Q