为什么filter_var()的FILTER_SANITIZE_STRING过滤器将单引号编码为'
,将双引号编码为"
,而htmlentities()将单引号编码为'
,将双引号编码为{{1 }}?
代码示例:
"
输出:
<?php
$string = "Well that's \"different.\"";
echo "filter_var: ".filter_var($string, FILTER_SANITIZE_STRING)."\n";
echo "htmlentities: ".htmlentities($string, ENT_QUOTES)."\n";
echo "htmlspecialchars: ".htmlspecialchars($string, ENT_QUOTES)."\n";