我在 Zend Framework 应用程序中使用以下代码:
控制器:
$paramsOtherAction = $this->getRequest()->getParams();
$paramsOtherAction['action'] = 'otheraction'
$this->view->paramsOtherAction = $paramsOtherAction;
看法:
<a href="<?php echo $this->url($this->paramsOtherAction)?>"> Do other action with same params </a>
这很好用,除非参数中有任何字符需要转义(编码),比如 url。我怎样才能以最好的方式编码这个参数数组?
编辑:
我实际上正在搜索的是将 a 参数传递给 url 函数的可能性,以确保我的 url 参数被编码(为什么这不是标准的呢?)。