3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { //类常量 const constValue = "constValue"; //类属性 public $property = "properties"; //静态属性 static public $staticProperty = "staticProperty"; //普通函数 public function func() { } //静态函数 static public staticFunc() { } } $xxoo = new A; //访问实例的属性 print $xxoo->property; //访问实例的函数 print $xxoo->func(); //也可以借助实例来访问静态成员 print $xxoo->staticFunc(); //如果不借助实例,那就直接用类名加双冒号 print A::staticFunc(); print A::constValue;
Output for 5.4.0 - 5.4.11
Parse error: syntax error, unexpected 'staticFunc' (T_STRING), expecting variable (T_VARIABLE) in /in/tNJB3 on line 21
Process exited with code 255.
Output for 5.3.0 - 5.3.21
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /in/tNJB3 on line 21
Process exited with code 255.

preferences:
154.82 ms | 1395 KiB | 41 Q