Languages: English • 한국어 • (Add your language)
Verifies that an email is valid.
<?php is_email( $email ) ?>
if ( is_email( 'email@domain.com' ) ) { echo 'email address is valid.'; }
Does not grok i18n domains. Not RFC compliant.
Does not correctly test for invalid characters. This code does not distinguish email such as 123.dot@domain.com:
if ( ! preg_match('/^[a-z0-9-]+$/i', $sub ) ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); }
is_email() is located in
wp-includes/formatting.php
.
See: Data Validation article for an in-depth discussion of input and output sanitization.