3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 7.0.0 - 7.1.0
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 hhvm-3.10.0 - 3.12.0
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.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.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.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.