PHP出乎意料的T_FUNCTION /构造问题?

时间:2012-06-19 15:01:00

标签: php error-handling

我在Cake php中的代码看起来像:

public $ceff_instance = array();

public function __construct() {

    $this->ceff_instance = $this->wsMethod_GO();
}

protected $filedMethodMappings = $this->$ceff_instance;

$wsMethod_GO返回数组的位置。但是,它表示我尝试将unexpected T_FUNCTION数组放入$ceff_instance的行中有$filedMethodMappings。这是什么原因?

我无法理解我的生活。

1 个答案:

答案 0 :(得分:2)

protected $filedMethodMappings = $this->$ceff_instance;

您无法在方法之外设置使用$this

public $ceff_instance = array();
protected $filedMethodMappings = NULL;

public function __construct() {
    $this->ceff_instance = $this->wsMethod_GO();
    $this->filedMethodMappings = $this->$ceff_instance;
}

DEMO:http://codepad.org/1V6ChkY0