3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { //类常量 const constValue = "constValue"; //类属性 public $property = "properties"; //静态属性 static public $staticProperty = "staticProperty"; //普通函数 public function func() { } //静态函数 static public function staticFunc() { } } $xxoo = new A; //访问实例的属性 print $xxoo->property; //访问实例的函数 print $xxoo->func(); //也可以借助实例来访问静态成员 print $xxoo->staticFunc(); //如果不借助实例,那就直接用类名加双冒号 print A::staticFunc(); print A::constValue; print A::staticProperty;
Output for 7.0.0 - 7.2.8
propertiesconstValue Fatal error: Uncaught Error: Undefined class constant 'staticProperty' in /in/OmMc2:39 Stack trace: #0 {main} thrown in /in/OmMc2 on line 39
Process exited with code 255.
Output for 5.0.0 - 5.6.28
propertiesconstValue Fatal error: Undefined class constant 'staticProperty' in /in/OmMc2 on line 39
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/OmMc2 on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/OmMc2 on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/OmMc2 on line 6
Process exited with code 255.