3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace DummyTest\Lib { class TObject { public function __construct() { } } class TComponent extends \DummyTest\Lib\TObject { public function __construct() { parent::__construct(); } } class TSingletonComponent extends \DummyTest\Lib\TComponent { public function __construct() { parent::__construct(); } } class TDatabase extends \DummyTest\Lib\TSingletonComponent { public function __construct() { parent::__construct(); } public static function Init() { $db = new \DummyTest\Lib\Database\TPDO(); } } } namespace DummyTest\Lib\Database { class TDatabase extends \DummyTest\Lib\TComponent { public function __construct() { parent::__construct(); } } class TPDO extends \DummyTest\Lib\Database\TDatabase { protected $pdo; public function __construct() { parent::__construct(); echo serialize(\DummyTest\SystemConfig::Get('xxx')); // Fails in PHP } } } namespace DummyTest { class SystemConfig { protected static $config = array(); public function Get($name) { echo get_called_class().PHP_EOL; if(isset(static::$config[$name])) { return static::$config[$name]; } return null; } public function Set($name, $value) { static::$config[$name] = $value; } } SystemConfig::Set('xxx', 'yyy'); \DummyTest\Lib\TDatabase::Init(); }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught Error: Non-static method DummyTest\SystemConfig::Set() cannot be called statically in /in/1r5Um:61 Stack trace: #0 {main} thrown in /in/1r5Um on line 61
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Deprecated: Non-static method DummyTest\SystemConfig::Set() should not be called statically in /in/1r5Um on line 61 Deprecated: Non-static method DummyTest\SystemConfig::Get() should not be called statically in /in/1r5Um on line 39 DummyTest\SystemConfig s:3:"yyy";
Output for 7.3.32 - 7.3.33
DummyTest\SystemConfig s:3:"yyy";
Output for 5.6.7 - 5.6.28
Strict Standards: Non-static method DummyTest\SystemConfig::Set() should not be called statically in /in/1r5Um on line 61 Deprecated: Non-static method DummyTest\SystemConfig::Get() should not be called statically, assuming $this from incompatible context in /in/1r5Um on line 39 DummyTest\Lib\Database\TPDO Fatal error: Access to undeclared static property: DummyTest\Lib\Database\TPDO::$config in /in/1r5Um on line 50
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35
Strict Standards: Non-static method DummyTest\SystemConfig::Set() should not be called statically in /in/1r5Um on line 61 Strict Standards: Non-static method DummyTest\SystemConfig::Get() should not be called statically, assuming $this from incompatible context in /in/1r5Um on line 39 DummyTest\Lib\Database\TPDO Fatal error: Access to undeclared static property: DummyTest\Lib\Database\TPDO::$config in /in/1r5Um on line 50
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING in /in/1r5Um on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/1r5Um on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/1r5Um on line 2
Process exited with code 255.

preferences:
274.49 ms | 401 KiB | 353 Q