我有这个PHP文件:
<?php
namespace FrameWork\Controller;
abstract class ControllerBase
{
protected $action;
protected $vars;
public function __construct($action, $vars = NULL)
{
$this->action = $action;
$this->vars = $vars;
$this->populateVars();
}
public function run()
{
****BETWEEN HERE****
$r = new \ReflectionMethod($this, $this->action);
$params = $r->getParameters();
$funcParams[];
foreach($params as $param)
{
$paramName = $param->getName();
$funcParams[$paramName] = $this->vars[$paramName];
}
****AND HERE****
call_user_func_array(array($this, $this->action), $funcParams);
}
private function PopulateVars()
{
foreach($_GET as $key => $getVar)
{
$this->vars[$key] = $getVar;
}
foreach($_POST as $key => $postVar)
{
$this->vars[$key] = $postVar;
}
}
}
它是include
在另一个文件中,由于某种原因,我在include
上抛出异常。
Cannot use [] for reading
当我删除****BETWEEN HERE****
和****AND HERE****
之间的所有内容时,它会起作用(或者至少不会抛出相同的异常)。
知道发生了什么事吗?
答案 0 :(得分:1)
您是否尝试过更换
$funcParams[];
与
$funcParams = array();
我认为它会解决你的问题。