3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { const MY_CONST = 'value'; // 常量 static $staticVar = 'static'; // 属性必须声明其作用域 public $property = 'public'; public $instanceProp; protected $prot = 'protected'; // 当前类和子类可访问 private $priv = 'private'; // 仅当前类可访问 // 通过 __construct 来定义构造函数 public function __construct($instanceProp) { // 通过 $this 访问当前对象 $this->instanceProp = $instanceProp; } // 方法就是类中定义的函数 public function myMethod() { print 'MyClass'; } final function youCannotOverrideMe() { } public static function myStaticMethod() { print 'I am static'; } } echo MyClass::MY_CONST; // 输出 'value'; echo MyClass::$staticVar; // 输出 'static'; MyClass::myStaticMethod(); // 输出 'I am static';
Output for git.master, git.master_jit, rfc.property-hooks
valuestaticI am static

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
75.69 ms | 401 KiB | 8 Q