1

我在 cake php 中有如下代码:

public $ceff_instance = array();

public function __construct() {

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

protected $filedMethodMappings = $this->$ceff_instance;

where$wsMethod_GO返回一个数组。但是,它说unexpected T_FUNCTION我尝试将$ceff_instance数组放入$filedMethodMappings. 这是什么原因?

我这辈子都想不通。

4

1 回答 1

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;
}

演示:http ://codepad.org/1V6ChkY0

于 2012-06-19T18:00:26.000 回答