- var_dump: documentation ( source)
- preg_match: documentation ( source)
- function_exists: documentation ( source)
<?php
function checkEmail($email) {
return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
}
function checkEmail2($email) {
return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email);
}
if (function_exists('eregi')){
echo "eregi:\n";
var_dump(checkEmail("jim@example.com"));
var_dump(checkEmail("jim@example.comm"));
}
echo "preg_match:\n";
var_dump(checkEmail2("jim@example.com"));
var_dump(checkEmail2("jim@example.comm"));