2012-07-26 151 views
1

我更改ereg to preg_match以将mycode更新为PHP5.3。现在我在我的页面中看到这个警告。如何解决这个问题?警告:preg_match()[function.preg-match]:未知修饰符' - '

警告:

Warning: preg_match() [function.preg-match]: Unknown modifier '-' in C:\xampp\htdocs\share\configs\functions.php on line 2645 

旧代码:

if (!ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $dateOfBirth, $regs)) 

新代码(PHP 5.3):

if (!preg_match ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $dateOfBirth, $regs)) 

感谢

+0

[preg_match_all()\ [function.preg-match-all \]:unknown modifier'\]']的可能重复(http://stackoverflow.com/questions/396557/preg-match-all -function-preg-match-all-unknown-modifier)等等,看看右边的“相关”列表。 – 2012-07-26 08:51:54

回答

3

您需要添加delimiters

if (!preg_match ("/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})/", $dateOfBirth, $regs)) 
#    ^        ^
相关问题