2017-02-13 3 views
1

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? 

} 

내가 수업 시간에 배열 함수를 사용해야합니다.

이 오류가 표시됩니다.

Parse error: syntax error, unexpected '$this' (T_VARIABLE) in /var/www/html/

어떻게해야합니까?

감사합니다.

답변

2

이 시도 :

class XXX{ 

    $MyArray = array(); 

    public function __construct(){ 
     $this->MyArray["value"] = $this->ggGet("email"); 
    } 

    public function ggGet($str){ 
     return gGet($str); 
    } 

} 

사용 __construct()를 사용하면 클래스 내부 VAR 값을 시작해야 할 때마다.

관련 문제