如何在Laminas中从url参数中获取$id?

问题描述 投票:1回答:1

如果我的url是这样的 http:/localhostcustomerview7。

'route' => 'customer[:action[:id]]

我想用7作为editAction()的id,但我不能用

$id = (int) $this->params()->fromRoute('id' , '0')。

那么,我怎样才能得到它呢?谢谢你的帮助

php zend-framework laminas
1个回答
1
投票

解决方法是修改view.phtml

之前:

a href = $this->url('customer', ['action' => 'edit']) ?>

:

a href = $this->url('customer', ['action' => 'edit', 'id' => $customer->id])

有了这个身份证'你可以使用:$id = (int) $this->params()->fromRoute('id' , '0');在editAction()

© www.soinside.com 2019 - 2024. All rights reserved.