Zend Framework Url View Helper 是一个用于生成 URL 的视图助手。默认情况下,它会自动将 "id" 参数添加到生成的 URL 中。这是因为 Zend Framework 的 Url View Helper 默认使用了 "id" 作为路由参数。
如果您希望更改默认的 "id" 参数,可以通过以下方法进行更改:
'router' => [
'routes' => [
'my-route' => [
'type' => 'Segment',
'options' => [
'route' => '/my-route[/:action[/:id]]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => 'MyController',
'action' => 'index',
'id' => '1',
],
],
],
],
],
在上面的示例中,我们将默认的 "id" 参数更改为 "1"。
$this->url('my-route', ['id' => 2]);
这将生成一个 URL,其中 "id" 参数设置为 "2"。
总之,您可以通过更改默认路由参数或在视图文件中传递参数来更改 Zend Framework Url View Helper 默认添加的 "id" 参数。
领取专属 10元无门槛券
手把手带您无忧上云