php - 模块配置 Zend 框架 2 中的约束模式

标签 php zend-framework zend-framework2 design-patterns

是否可以将约束模式设置为仅数字和 &?

所以我可以制作一个像这样的 url:localhost/cms/user/multipledelete/1&2

我现在有以下配置,但它只允许数字。我希望 ID 可以是数字和 &。

这是我的代码:

'route'    => '/user[/:action][/:id][/sort/:order_by][/:order][/page/:page]',
   'constraints' => array(
   'action' => '(?!\bsort\b)(?!\bpage\b)[a-zA-Z][a-zA-Z0-9_-]*',
   'id'     => '[0-9]+',
   'order_by' => '[a-zA-Z][a-zA-Z0-9_-]*',
   'order' => 'asc|desc',
   'page' => '[0-9]+',
 ),

最佳答案

使用以下模式:

[0-9&]+

喜欢:

'constraints' => array(
   'action' => '(?!\bsort\b)(?!\bpage\b)[a-zA-Z][a-zA-Z0-9_-]*',
   'id'     => '[0-9&]+',
   'order_by' => '[a-zA-Z][a-zA-Z0-9_-]*',
   'order' => 'asc|desc',
   'page' => '[0-9]+',
),

关于php - 模块配置 Zend 框架 2 中的约束模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15966590/

相关文章:

php插入数据库出错

php - 获取文件夹中最近更新文件的文件时间

php - Zend 框架 : How can I tap into the final view output before it's sent to the browser?

php - Zend 框架和 XML/XSLT 集成

php - 在 zend 框架下载中找不到 zf.bat

html - 在 View 脚本中使用 css DIV 区域

php - 使用 Zend Framework 2 中的 FormElement ViewHelper 呈现自定义表单元素

php - 使用 MySQL 在数据库中使用不同的表类型是一种好习惯吗?

php - Zend DB 如何管理数据库连接

javascript - setInterval() 和 AJAX 的高 CPU 使用率和同步 XMLHttpRequest 警告