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://codercto.com/courses/l/5.html
Practical Django Projects, Second Edition
James Bennett / Apress / 2009 / 44.99
Build a django content management system, blog, and social networking site with James Bennett as he introduces version 1.1 of the popular Django framework. You’ll work through the development of ea......一起来看看 《Practical Django Projects, Second Edition》 这本书的介绍吧!