CakePHP:如何在视图中使用Controller :: referer()

eme*_*his 5 php cakephp cakephp-2.0

我收到以下错误:

Strict (2048): Non-static method Controller::referer() should not be called statically,
assuming $this from incompatible context [APP/View/Questions/admin_edit.ctp, line 20]
Run Code Online (Sandbox Code Playgroud)

由此引起的:

//in app/View/Questions/admin_edit.ctp
echo $this->Html->link('Cancel', Controller::referer() );
Run Code Online (Sandbox Code Playgroud)

为什么?

mar*_*ark 15

你没有.您改为使用请求对象:

$this->request->referer();
Run Code Online (Sandbox Code Playgroud)

控制器在内部不做任何其他事情

小心:引用者可能是空的,因此在这种情况下你可能想要提供一个后备.

还要注意可选的param $ local:

@param boolean $local If true, restrict referring URLs to local server