note 101693 modified in filter.filters.validate by danbrown
| From: | danbrown@php.net | Date: | Wed, 05 Jan 2011 18:46:35 +0000 |
| Subject: | note 101693 modified in filter.filters.validate by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-175462@lists.php.net to get a copy of this message | ||
FILTER_VALIDATE_EMAIL does NOT allow incomplete e-mail addresses to be validated as mentioned by
Tomas.
Using the following code:
<?php
$email = "clifton@example"; //Note the .com missing
echo "PHP Version: ".phpversion().'<br>';
if(filter_var($email, FILTER_VALIDATE_EMAIL)){
echo $email.'<br>';
var_dump(filter_var($email, FILTER_VALIDATE_EMAIL));
}else{
var_dump(filter_var($email, FILTER_VALIDATE_EMAIL));
}
?>
Returns:
PHP Version: 5.2.14 //On MY server, may be different depending on which version you have installed.
bool(false)
While the following code:
<?php
$email = "clifton@example.com"; //Note the .com added
echo "PHP Version: ".phpversion().'<br>';
if(filter_var($email, FILTER_VALIDATE_EMAIL)){
echo $email.'<br>';
var_dump(filter_var($email, FILTER_VALIDATE_EMAIL));
}else{
var_dump(filter_var($email, FILTER_VALIDATE_EMAIL));
}
?>
Returns:
PHP Version: 5.2.14 //On MY server, may be different depending on which version you have installed.
clifton@example.com
string(16) "clifton@example.com"
This feature is only available for PHP Versions (PHP 5 >= 5.2.0) according to documentation. So
make sure your version is correct.
Cheers,
Clifton
--was--
FILTER_VALIDATE_EMAIL does NOT allow incomplete e-mail addresses to be validated as mentioned by
Tomas.
Using the following code:
<?php
$email = "clifton@some"; //Note the .com missing
echo "PHP Version: ".phpversion().'<br>';
if(filter_var($email, FILTER_VALIDATE_EMAIL)){
echo $email.'<br>';
var_dump(filter_var($email, FILTER_VALIDATE_EMAIL));
}else{
var_dump(filter_var($email, FILTER_VALIDATE_EMAIL));
}
?>
Returns:
PHP Version: 5.2.14 //On MY server, may be different depending on which version you have installed.
bool(false)
While the following code:
<?php
$email = "clifton@some.com"; //Note the .com added
echo "PHP Version: ".phpversion().'<br>';
if(filter_var($email, FILTER_VALIDATE_EMAIL)){
echo $email.'<br>';
var_dump(filter_var($email, FILTER_VALIDATE_EMAIL));
}else{
var_dump(filter_var($email, FILTER_VALIDATE_EMAIL));
}
?>
Returns:
PHP Version: 5.2.14 //On MY server, may be different depending on which version you have installed.
clifton@some.com
string(16) "clifton@some.com"
This feature is only available for PHP Versions (PHP 5 >= 5.2.0) according to documentation. So
make sure your version is correct.
Cheers,
Clifton
http://php.net/manual/en/filter.filters.validate.php