Simple Email Validation
View Single Post
02-21-2008, 02:50 AM
Join Date: Apr 2007
A good first thing to do would be to switch from using
modifier). This will improve the running time of the function to around a quarter of that of eregi! Also, this is a person preference more than anything, I don't like to see functions where a conditional is processed which determines a boolean response which is assigned to a local variable. Why not just use a single line of code?
return (bool) preg_match(...);
For the regular expression itself, you've made an ok start. However, this falls victim of a hugely common bug in many "validation" checks: it would flag
as invalid, when it's not. You simply need to allow the
character in the appropriate place.
Since you're only checking to see if the pattern matches or not, there's no need to use capturing groups
so you can same some time and effort (on the parser's part) by making them non-capturing
View Public Profile
Send a private message to Salathe
Visit Salathe's homepage!
Find More Posts by Salathe