PHP [preg_match] No ending delimiter '^' found in
in php with 0 comment

PHP [preg_match] No ending delimiter '^' found in

in php with 0 comment

今天写路由正则过滤的时候出现了这个问题。

解答网址:https://forums.phpfreaks.com/topic/255584-warning-preg-match-functionpreg-match-no-ending-delimiter-found-in/

The problem is you're not including a delimiter before and after the pattern, therefore PHP is thinking that your delimiter is "^", but of course you're missing the closing delimiter. This is an easy problem to solve, just have a quick read about delimiters in the manual first.

^[1-9]\d*$

改为

/^[1-9]\d*$/

即可。

Comments are closed.