Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 是否有优先权管理规则?_Php_Yii - Fatal编程技术网

Php 是否有优先权管理规则?

Php 是否有优先权管理规则?,php,yii,Php,Yii,在我的Yii测试应用程序中,我有两种类型的URL。示例如下:- http://localhost/testapp/index.php?r=post/view&id=1&slug=maximizing-profit http://localhost/testapp/index.php?r=category/view&slug=investment 第一个URL有2个参数id和slug而第二个参数只有slug参数 在我的urlManager中,我有两条规则 <cont

在我的Yii测试应用程序中,我有两种类型的URL。示例如下:-

http://localhost/testapp/index.php?r=post/view&id=1&slug=maximizing-profit
http://localhost/testapp/index.php?r=category/view&slug=investment
第一个URL有2个参数
id
slug
而第二个参数只有
slug
参数

在我的urlManager中,我有两条规则

<controller:\w+>/<action:\w+>/<slug:[a-zA-Z0-9-]+>/' => '<controller>/<action>
<controller:\w+>/<action:\w+>/<id:\d+>/<slug:[a-zA-Z0-9-]+>/' => '<controller>/<action>
另一只手上的第二个URL显示良好

http://localhost/testapp/category/view/investment

urlManager中是否有我们应该遵循的规则优先级?

将使用任何首先匹配URL的规则

在您的情况下,只需切换两个规则的顺序。这是因为您的slug规则也与数字匹配,包括那些只有ID的规则。如果您切换规则,将首先捕获那些以数字作为ID的规则,然后捕获那些具有非数字ID的规则。

可能重复的规则。像这样的问题每隔几周就会出现一次。请先在这里做一些研究。
http://localhost/testapp/category/view/investment