简体   繁体   English

PHP filter_var函数什么都不输出

[英]PHP filter_var function outputs nothing

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. 同样,带有FILTER_SANITIZE_STRINGfilter_var也做同样的事情。 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 注意:使用未定义的常量FILTER_SANITZE_EMAIL-在第4行的/var/www/html/test.php中假定为'FILTER_SANITZE_EMAIL'

Warning: filter_var() expects parameter 2 to be long, string given in /var/www/html/test.php on line 4 SANITIZED-EMAIL 警告:filter_var()期望参数2长,字符串在第4行SANITIZED-EMAIL的/var/www/html/test.php中给出

It has to be FILTER_SANITIZE_EMAIL not FILTER_SANITZE_EMAIL - so it's just a typo. 它必须是FILTER_SANITIZE_EMAIL而不是FILTER_SANITZE_EMAIL所以这只是一个错字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM