开发者

php - Warning: filter_var() [function.filter-var]: Unknown modifier '+'

开发者 https://www.devze.com 2023-04-02 09:25 出处:网络
I am trying to use a regular expression from http://www.regular-expressions.info/email.html, specifically:

I am trying to use a regular expression from http://www.regular-expressions.info/email.html, specifically:

[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?

However when using th开发者_如何学Gois along with:

filter_var($email, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>$pattern)))

It brings up the error:

Warning: filter_var() [function.filter-var]: Unknown modifier '+'

Does anyone know how to fix this?


Your regexp is missing delimiters. Inserting, say, a semicolon before and after the pattern will fix this.

However, you should really use filter_var($email, FILTER_VALIDATE_EMAIL) instead of rolling out your own (incorrect) regexp.

0

精彩评论

暂无评论...
验证码 换一张
取 消