我刚刚开始与Symfony合作.我下载了sf_sandbox,我遇到了$ sf_params的问题.当我尝试使用任何方法时,例如$sf_params->has('status')我收到错误:
注意:未定义的变量:第14行/var/www/sf_sandbox/apps/frontend/modules/login/actions/actions.class.php中的sf_params致命错误:在/中的非对象上调用成员函数has()第14行的var/www/sf_sandbox/apps/frontend/modules/login/actions/actions.class.php
这是块:
public function executeIndex() {
if ($sf_params->has('status') && $sf_params->has('message')) { // <--line 14
if ($sf_params->get('status') == 'failed') {
$this->message = $sf_params->get('message');
}
}
}
Run Code Online (Sandbox Code Playgroud)
正如The.Anti.9所述,在Action文件中编写代码时必须使用$ request.您需要更换函数定义,如下所示:
public function executeIndex(sfWebRequest $request) {
$request->getParameter("status");
...
Run Code Online (Sandbox Code Playgroud)
我希望有所帮助.
编辑:刚刚意识到你回答了自己的问题.
| 归档时间: |
|
| 查看次数: |
717 次 |
| 最近记录: |