我昨天在班上发现了一个奇怪的问题 - 希望你知道一些答案.考虑这样一个类:
class Person {
public $height = 90;
public $weight = $this->height * 0.8;
}
Run Code Online (Sandbox Code Playgroud)
此类返回错误"Parse error:syntax error,unexpected T_VARIABLE",似乎我无法在类中声明变量本身.我是否只能将"静态"值设置为类中的变量(我的意思是像直接声明像字符串一样的静态或int不像"静态$ var ='xyz'"那样的静态;为什么会发生这种情况?
谢谢,Kalreg.