I have the following code:
$email = 'test@example.com';
echo $email.'<br>';
echo filter_var('test@example.com',FILTER_SANITZE_EMAIL).' SANITIZED-EMAIL';
and it the output is as follows:
test@example.com
SANITIZED-EMAIL
Clearly the email is completely turned into an empty string. Similarly the filter_var
with FILTER_SANITIZE_STRING
does the same thing. What am I missing here?
Your code does give errors:
Notice: Use of undefined constant FILTER_SANITZE_EMAIL - assumed 'FILTER_SANITZE_EMAIL' in /var/www/html/test.php on line 4
Warning: filter_var() expects parameter 2 to be long, string given in /var/www/html/test.php on line 4 SANITIZED-EMAIL
It has to be FILTER_SANITIZE_EMAIL
not FILTER_SANITZE_EMAIL
- so it's just a typo.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.