PHP filter_var function outputs nothing
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_SANITIZE_STRING does the same thing. What am I missing here?
1 Answers PHP filter_var function outputs nothing
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_SANITZE_EMAIL - so it's just a typo.