[PHP]htmlentities() 函数
定义和用法
htmlentities() 函数把字符转换为 HTML 实体。
语法
htmlentities(string,quotestyle,character-set)
| 参数 | 描述 |
|---|---|
| string | 必需。规定要转换的字符串。 |
| quotestyle |
可选。规定如何编码单引号和双引号。
|
| character-set |
可选。字符串值,规定要使用的字符集。
|
提示和注释
提示:无法被识别的字符集将被忽略,并由 ISO-8859-1 代替。
例子
<html>
<body>
<?php
$str = "John & 'Adams'";
echo htmlentities($str, ENT_COMPAT);
echo "<br />";
echo htmlentities($str, ENT_QUOTES);
echo "<br />";
echo htmlentities($str, ENT_NOQUOTES);
?>
</body>
</html>
浏览器输出:
John & 'Adams'
John & 'Adams'
John & 'Adams'
如果在浏览器中查看源代码,会看到这些 HTML:
<html>
<body>
John & 'Adams'<br />
John & 'Adams'<br />
John & 'Adams'
</body>
</html>
[PHP]htmlentities() 函数的更多相关文章
- htmlentities() 函数
Definition and Usage定义和用法 The htmlentities() function converts characters to HTML entities.htmlentit ...
- html_entity_decode与htmlentities函数
htmlentities() 函数把字符转换为 HTML 实体.html_entity_decode() 函数把 HTML 实体转换为字符.例子:$a = '<div> <p> ...
- PHP 把字符转换为 HTML 实体 - htmlentities() 函数
定义和用法 htmlentities() 函数把字符转换为 HTML 实体. 语法 htmlentities(string,quotestyle,character-set) 参数 描述 string ...
- php htmlentities()函数 语法
php htmlentities()函数 语法 作用:把字符转换为 HTML 实体 语法:htmlentities(string,flags,character-set,double_encode) ...
- php htmlentities函数的问题
看到在细说php第二版教程中的函数htmlentities 例子,实际实验没有效果 $str = "一个 'quote' 是<b>bold</b>";ech ...
- 153-PHP htmlentities函数
<?php //定义一个HTML代码字符串 $str=<<<HTM <a href=#><b><i>到一个网址的链接</i>&l ...
- php常用字符串函数小结
php内置了98个字符串函数(除了基于正则表达式的函数,正则表达式在此不在讨论范围),能够处理字符串中能遇到的每一个方面内容,本文对常用字符串函数进行简单的小结,主要包含以下8部分:1.确定字符串长度 ...
- PHP常用字符串的操作函数
字符串转换类函数 addcslashes函数:以C语言风格使用反斜线转义字符串中的字符 addslashes函数:使用反斜线引用字符串 chop函数:清除字符串中的连续空格 get_html_tran ...
- PHP字符串函数
php字符串处理函数大全 addcslashes — 为字符串里面的部分字符添加反斜线转义字符addslashes — 用指定的方式对字符串里面的字符进行转义bin2hex — 将二进制数据转换成十六 ...
随机推荐
- ios中UIButton选中状态切换
关于UIButton的事件枚举有许多,平时用的少所以很多的都不是很清楚,今天了解了下,看了以前的代码,觉得在UIButton选中时操作写了许多冗余代码,而忽略了UIButton一个很重要的属性,如下: ...
- Golang-interface(四 反射)
github:https://github.com/ZhangzheBJUT/blog/blob/master/reflect.md 一 反射的规则 反射是程序执行时检查其所拥有的结构.尤其是类型的一 ...
- android117 下拉列表
- OpenCMS integration with Spring MVC--reference
ref from:http://blogs.indrajitpingale.com/?p=8 http://blog.shinetech.com/2013/04/09/integrating-spri ...
- python中HTMLParser简单理解
找一个网页,例如https://www.python.org/events/python-events/,用浏览器查看源码并复制,然后尝试解析一下HTML,输出Python官网发布的会议时间.名称和地 ...
- Disruptor框架
http://developer.51cto.com/art/201306/399370.htm
- Oracle批量加注释,并生成html
excel连接列名生成oracle注释 notes: A2为列名,B2为注释 ="comment on column ColAgreementHeader."&A2& ...
- Callable、Future和FutureTask使用说明
普通的创建线程,一种是直接继承Thread,另外一种就是实现Runnable接口.但是这两种都无法在执行完任务之后获取执行结果,Callable.Future就提供了这样的便利. Future的方 ...
- 【原】Spring与MongoDB集成:配置
MongoDB的API提供了DBObject接口来实现BSONObject的操作方法,BasicDBObject是具体实现.但是并没有提供DBObject与BeanObject的转换.在还没有了解到与 ...
- hdu 1093 A+B for Input-Output Practice (V)
A+B for Input-Output Practice (V) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3276 ...