代码之家  ›  专栏  ›  技术社区  ›  Rodrigo Souza

如何从url中删除未使用的参数?

  •  1
  • Rodrigo Souza  · 技术社区  · 15 年前

    我使用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' => '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'));
    

    这样,一开始,我有这样的网址

    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

    我该怎么解决?

    1 回复  |  直到 13 年前
        1
  •  5
  •   Vika    15 年前

    调用时需要重置参数 url 帮手。

    $this->url(array('controller'=>'index','action'=>'index'),null,true);

    null 如果要使用当前路由。
    第三个参数指示是否重置参数。它是 false 所以,把它设置为 true 删除现有参数。

    推荐文章