您可以自定義的助手:
class My_View_Helper_UrlHttpQuery extends Zend_View_Helper_Abstract
{
public function urlHttpQuery($query)
{
$urlHelper = $this->view->getHelper('url');
$params = func_get_args();
array_shift($params);//removing first argument
$url = call_user_func_array(($urlHelper, 'url'), $params);
if(!is_string($query)) { //allow raw query string
$query = array($query);
$query = http_build_query($query);
}
if(!empty($query) {
$url .= '?' . ltrim('?', $query);
}
return $url;
}
}
你註冊這個幫手與視圖後,您可以由於上游代碼沒有按使用這樣<a href="<?=$this->urlHttpQuery(array('find_loc'=>'New+York', 'find_name'=>'starbucks'), array('page' => $this->next), 'routename', $otherUrlHelperParams) ?>" class="next">Next Page</a>
有一個PHP函數,建立查詢字符串http:// www.php.net/manual/en/function.http-build-query.php –