PHP FILTER_SANITIZE_SPECIAL_CHARS 过滤器
PHP 教程
· 2019-01-25 20:29:14
定义和用法
FILTER_SANITIZE_SPECIAL_CHARS 过滤器对特殊字符进行 HTML 转义。
该过滤器用于转义 "<>& 以及 ASCII 值在 32 值以下的字符。
- Name: "special_chars"
- ID-number: 515
可能的标志:
- FILTER_FLAG_STRIP_LOW - 去除 ASCII 值在 32 以下的字符
- FILTER_FLAG_STRIP_HIGH - 去除 ASCII 值在 32 以上的字符
- FILTER_FLAG_ENCODE_HIGH - 编码 ASCII 值在 32 以上的字符
实例
<?php $url="Is Peter <smart> & funny?"; var_dump(filter_var($url,FILTER_SANITIZE_SPECIAL_CHARS)); ?>
上面代码的浏览器输出如下所示:
string(37) "Is Peter <smart> & funny?"
如果您在浏览器中查看源代码,会看到以下 HTML:
string(37) "Is Peter <smart> & funny?"
点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html
Automate This
Christopher Steiner / Portfolio / 2013-8-9 / USD 25.95
"The rousing story of the last gasp of human agency and how today's best and brightest minds are endeavoring to put an end to it." It used to be that to diagnose an illness, interpret legal docume......一起来看看 《Automate This》 这本书的介绍吧!