Php 如何从url中删除未使用的参数?
我正在使用Zend框架和URL视图帮助器创建URL 我的导航中有一些类似的行:Php 如何从url中删除未使用的参数?,php,zend-framework,zend-framework-routing,Php,Zend Framework,Zend Framework Routing,我正在使用Zend框架和URL视图帮助器创建URL 我的导航中有一些类似的行: $this->url(array('controller' => 'index', 'action' => 'index')) $this->url(array('controller' => 'who', 'action' => 'view', 'id' => $row->who_id)); $this->url(array('controller' =>
$this->url(array('controller' => 'index', 'action' => 'index'))
$this->url(array('controller' => 'who', 'action' => 'view', 'id' => $row->who_id));
$this->url(array('controller' => 'projects', 'action' => 'view', 'id' => $row->mai_id));
$this->url(array('controller' => 'content', 'action' => 'view', 'type' => 'theater', 'id' => $row->the_id));
$this->url(array('controller' => 'shows', 'action' => 'view'));
这样,首先,我有一些像这样的URL
http://ccgss.local/information/location
http://ccgss.local/who/view/id/1
但是当我访问另一个带有更多参数的链接时,比如http://ccgss.local/content/view/id/1/type/theater
它弄乱了仍然存在的参数:http://ccgss.local/who/view/id/1/type/theater
我的意思是,当我访问另一个页面时,参数不会被清除
如何解决此问题?调用
url
helper时,需要重置参数
$this->url(数组('controller'=>'index','action'=>'index'),null,true)
第二个参数是要使用的路由的名称。如果要使用当前路线,请将其保持为空。第三个参数说明是否重置参数。默认情况下,它是
false
。
因此,只需将其设置为
true
即可摆脱现有参数。调用url
帮助程序时需要重置参数
$this->url(数组('controller'=>'index','action'=>'index'),null,true)
第二个参数是要使用的路由的名称。如果要使用当前路线,请将其保持为空。第三个参数说明是否重置参数。默认情况下,它是
false
。
因此,只需将其设置为true
,即可去除现有参数