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.35
Parse error: syntax error, unexpected 'staticProperty' (T_STRING), expecting variable (T_VARIABLE) in /in/2qq4W on line 12
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /in/2qq4W on line 12
Process exited with code 255.

preferences:
180.84 ms | 1395 KiB | 72 Q