2012-07-26 148 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)) 
#    ^        ^
相關問題