Posts Tagged ‘functions’

PHP Validations

Posted: 10th August 2010 by Babar Shafiq in Programming
Tags: , , ,

Validate Email We can perform an email validation through this function. function isValidEmail($email){ return eregi(‘^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$’, $email); } After fainted for a few seconds when i saw unreal4u finding, i decided to throw up preg_match solution instead. function isValidEmail($email){ return preg_match(‘/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i’, $email); } PHP 5.2 and above. function fnValidateEmail($email) { return filter_var($email, FILTER_VALIDATE_EMAIL); } Sanitize Email […]