Reputation: 53
I have the following code:
$email = '[email protected]';
echo $email.'<br>';
echo filter_var('[email protected]',FILTER_SANITZE_EMAIL).' SANITIZED-EMAIL';
and it the output is as follows:
[email protected]
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?
Upvotes: 0
Views: 207
Reputation: 6742
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.
Upvotes: 2