可能重复:
escape method is not supported by view page in admin area or backend of site in zend framework?
我已经在我的localhost上正确安装了zend框架并获得了zend框架默认索引页面。现在我在视图页面中使用escape方法并运行页面,然后显示以下错误: -
致命错误:调用未定义的函数escape().....
我没有获得删除此错误的解决方案,我已使用Zend_Tool命令设置虚拟主机并创建站点结构,如创建项目myproject。
我有正确的目录结构,当我在localhost上运行我的网站时,它显示了一个zend默认索引页面。所以我假设zend已在我的系统上正确安装。由zend_tool创建的目录结构有一个空白库文件夹,并且在myproject文件夹的已创建目录结构中没有显示bin文件夹。
我正在使用最新版本的zend framework 1.11.11
我很困惑为什么escape()方法不起作用
我在控制器中使用以下代码: -
$this->view->assign('username', 'Username');
$this->view->assign('password', 'Password');
$this->view->assign('rememberMe', 'Remember Me');
我在视图页面中调用escape方法如下: -
<td id="userlogin" align="left" width="30%"><?php echo escape($this->username);?>:</td>
在我的控制器中,我不包含任何文件。它只是一个简单的控制器文件: -
<?php
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// action body
$request = $this->getRequest();
$this->view->assign('username', 'Username');
$this->view->assign('password', 'Password');
$this->view->assign('rememberMe', 'Remember Me');
}
}
我发错的地方请告诉我。
答案 0 :(得分:1)
escape()
不是php函数。
如果你想使用ZF的视图助手Zend_View_Helper_Escape,你需要在视图对象上调用它:
<?php echo $this->escape($this->username);?>
答案 1 :(得分:0)
尝试$this->escape($this->username);
而非escape($this->username);