Alternative to filter
Possible Duplicate:
filter_var in php 5.3.8
I recently upgraded to php 5.3.8 and I am having problem validating an email address a user enters into a registration form using "filter_var". I want to ensure that when a valid email address is entered I post it to a database and if for some reason the format of the email address is incorrect I inform the user to enter a valid email address. So I checked php.net and it turns out filter_var does not exist in php 5.3.8 Does anyone know of an alternative to filter_var in php 5.3.8
如果您只关心提供的电子邮件地址在语法上有效,例如符合RFC 2822标准,则此正则表达式可用于:
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[x01-x08x0bx0cx0e-x1fx21x23-x5bx5d-x7f]|[x01-x09x0bx0cx0e-x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[x01-x08x0bx0cx0e-x1fx21-x5ax53-x7f]|[x01-x09x0bx0cx0e-x7f])+)])
filter_var
(PHP 5 >= 5.2.0)
filter_var — Filters a variable with a specified filter
The docs say it exists just fine in 5.3.8, so you should be able to just use it...
链接地址: http://www.djcxy.com/p/92692.html上一篇: 未定义的PHP函数过滤器
下一篇: 替代过滤器