Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.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 CodeIgniter路由和正则表达式_Php_Regex_Codeigniter_Routes - Fatal编程技术网

Php CodeIgniter路由和正则表达式

Php CodeIgniter路由和正则表达式,php,regex,codeigniter,routes,Php,Regex,Codeigniter,Routes,我正在尝试在CodeIgniter上创建一个路由,它匹配3个数字,后面跟一个连字符,后面跟任何东西。到目前为止,我一点运气都没有。我尝试了以下方法: $route['([0-9]+)-([a-zA-Z0-9]+)'] = 'product/index/$1'; $route['([0-9]+)([a-zA-Z0-9-]+)'] = 'product/index/$1'; $route['(:num)-(:any)'] = 'product/index/$1'; $route['([0-9]{3}

我正在尝试在CodeIgniter上创建一个路由,它匹配3个数字,后面跟一个连字符,后面跟任何东西。到目前为止,我一点运气都没有。我尝试了以下方法:

$route['([0-9]+)-([a-zA-Z0-9]+)'] = 'product/index/$1';
$route['([0-9]+)([a-zA-Z0-9-]+)'] = 'product/index/$1';
$route['(:num)-(:any)'] = 'product/index/$1';
$route['([0-9]{3})-(:any)'] = 'product/index/$1';
$route['(\d{3})-(:any)'] = 'product/index/$1';
等等。有人知道我怎么做吗?

看起来CodeIgniter没有使用标准的正则表达式

试试这些:

\d{3}\-* \d{3}-* \d{3}\-:任何 \d{3}-:任何 其中一个应该有效


有关更多信息,请参见

,这可能是一个参数问题。 也许你应该试试:

$route['([0-9]+)-([a-zA-Z0-9]+)'] = 'product/index/$1/$2';

既然您正在捕获两个变量,似乎应该将它们都传递给函数。

为什么同一页有5条路由?