PHP代码
class XXX{
public function ggGet($str){
return gGet($str); // This is ok working gGet is global function
}
public static $Array = array ( "value" => $this->ggGet("email")); // This code is error Why?
}
我必须在类中使用数组中的函数。
我看到了这个错误。
解析错误:语法错误,意外' $ this' / var / www / html /
中的(T_VARIABLE)
我该怎么办?
谢谢。
答案 0 :(得分:2)
试试这个:
class XXX{
$MyArray = array();
public function __construct(){
$this->MyArray["value"] = $this->ggGet("email");
}
public function ggGet($str){
return gGet($str);
}
}
每次需要在类中的var中启动值时,请使用__construct()。