PHP banner

Hoo boy, we have to do this all the time and a quick Google tells me everyone has their favourite little tricks. Some even work. Here are the results of an exercise in e-mail validation using two different PHP options, namely:

PHP’s Validate filters

filter_var($email, FILTER_VALIDATE_EMAIL));

PHP preg_match()

preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*\@([a-z0-9])*(\.([a-z0-9])([-a-z0-9_-])([a-z0-9])+)*$/i', $email);

See demo page here…



By foxbeefly

PHP / MySQL Developer. HTML, CSS and some JavaScript.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.