这几行代码有问题
当我转到localhost/站点工作时
当我转到localhost时,欢迎站点不工作!转到echo=>string,失败
当我转到localhost/webwell/other站点时,工作,但下面有错误
严格标准:call_user_func_array()要求参数1是一个有效的回调,非静态方法welcome::king()不应在bootstrap.php中的第=>行call_user_filc_array([$this->_controller,$this-->_method],$this->_params)中静态调用;
引导程序中的代码.php
if(empty($url))
{
$name_controller = ROOT;
$this->_requireController($name_controller);
$contro = new $name_controller();
$contro->$name_controller();
}
else
{
$this->_controller = $url[0];
if(isset($url[1]))
{
$this->_methode = $url[1];
unset($url[0]);
unset($url[1]);
$this->_params = $url ? array_values($url) : [];
echo "222";
}
else
{
echo "string";
}
$this->_requireController($this->_controller);
$contro = new $this->_controller();
if(method_exists($contro, $this->_methode))
{
call_user_func_array([$this->_controller, $this->_methode], $this->_params);
}
else
{
echo 'FAIL';
}
}
}
Controllers/welcome.php
类欢迎扩展控制器{
function __construct()
{
parent::__construct();
}
public function welcome()
{
echo "work!";
}
public function other()
{
echo "Other Work";
}
public function other_arg($arg)
{
echo "Other Work with ".$arg;
}
}
您可以将其设置为静态,并将其调用为非静态函数,如下所示:
static::run();
或者你试过这个吗
$this->-controller->$this->_methode($args);
而不是
call_user_func_array([$this->_controller, $this->_methode], $this->_params);
以下是loclahost/webwell/other上的错误:222
严格标准:call_user_func_array()要求参数1是有效的回调,非静态方法welcome::test()不应在C:''xamp-server''htdocs''bootstrap.php的第177行静态调用
其他工作