Friday, February 12, 2010

Did you use filter_var function in PHP?

If you are using php 5.2 or above for your development and haven't checked the function filter_var then you must check it.

With a greater functionality for filtering  and validating your variables.

For eg. till then you must have used the regular expression to validate the email address. Here is how you can do it with filter_var function with 10X faster :
var_dump(filter_var('bob@example.com', FILTER_VALIDATE_EMAIL));

So just check it out if you have not checked it yet:
http://in2.php.net/manual/en/function.filter-var.php

Lalit

No comments:

Post a Comment