html_entity_decode() 函数
html_entity_decode() 函数
定义和用法
The html_entity_decode() function converts HTML entities to characters.
html_entity_decode()函数的作用是:转换HTML字符编码为字符。
The html_entity_decode() function is the opposite of htmlentities()
html_entity_decode()函数的作用是和htmlentities()相反的。
Syntax
语法
html_entity_decode(string,quotestyle,character-set) |
| Parameter参数 | Description描述 |
|---|---|
| string | Required. Specifies the string to decode 必要参数。指定需要解码的字符串对象 |
| quotestyle | Optional. Specifies how to decode single and double quotes. 可选参数。定义如何对单引号和双引号进行编码。默认值是ENT_COMPAT。 The available quote styles are:
|
| character-set | Optional. A string that specifies which character-set to use. 可选参数。指定使用什么样的字符串设置 Allowed values are:
|
Tips and Notes
注意点
Note: Unrecognized character-sets will be ignored and replaced by ISO-8859-1.
注意:如果不可识别的字体设置[character-sets]将被忽略,并且会使用ISO-8859-1代替。
Example 1
案例1
<?php $str = "Jane & 'Tarzan'"; echo html_entity_decode($str); echo "<br />"; echo html_entity_decode($str, ENT_QUOTES); echo "<br />"; echo html_entity_decode($str, ENT_NOQUOTES); ?> |
The browser output of the code above will be:
上述代码将输出下面的结果:
Jane & 'Tarzan' Jane & 'Tarzan' Jane & 'Tarzan' |
If you select "View source" in the browser window, you will see the following HTML:
如果你在浏览器中选择“查看源文件”,你将会看到下面的HTML数据流:
<html> <body> Jane & 'Tarzan'<br /> Jane & 'Tarzan'<br /> Jane & 'Tarzan' </body> </html> |
Example 2
案例2
<html> <body> <?php $str = "My name is Øyvind Åsane. I'm Norwegian"; echo html_entity_decode($str, ENT_QUOTES, "ISO-8859-1"); ?> </body> </html> |
The browser output of the code above will be:
上述代码将输出下面的结果:
My name is Øyvind Åsane. I'm Norwegian |
If you select "View source" in the browser window, you will see the following HTML:
如果你在浏览器中选择“查看源文件”,你将会看到下面的HTML数据流:
<html> <body> My name is Øyvind Åsane. I'm Norwegian </body> </html> |
html_entity_decode() 函数的更多相关文章
- PHP html_entity_decode() 函数
html_entity_decode(string,flags,character-set) 把 HTML 实体转换为字符. html_entity_decode() 函数是 htmlentities ...
- html_entity_decode与htmlentities函数
htmlentities() 函数把字符转换为 HTML 实体.html_entity_decode() 函数把 HTML 实体转换为字符.例子:$a = '<div> <p> ...
- php解码“&#”编码的中文用函数html_entity_decode()
遇到类似 ' 这种编码的字,我们可以用html_entity_decode()函数来解码. html_entity_decode() 函数把 HTML 实体转换为字符. 语法 html_entity_ ...
- PHP常用字符串的操作函数
字符串转换类函数 addcslashes函数:以C语言风格使用反斜线转义字符串中的字符 addslashes函数:使用反斜线引用字符串 chop函数:清除字符串中的连续空格 get_html_tran ...
- htmlentities,html_entity_decode,addslashes
PHP htmlspecialchars_decode() 函数 PHP htmlspecialchars() 函数 PHP html_entity_decode() 函数 PHP中混淆的三组函数总结 ...
- PHP常用函数大全
usleep() 函数延迟代码执行若干微秒.unpack() 函数从二进制字符串对数据进行解包.uniqid() 函数基于以微秒计的当前时间,生成一个唯一的 ID.time_sleep_until() ...
- PHP常用函数备用
刚学习php的时候,我也为记忆php函数苦恼不已.认为干嘛记忆这么枯燥无味的东西呢?用的时候查一下手册不就行了吗?但是当时因为身在辅导机构,还是记忆了一大堆自己并不感兴趣的函数. 由此就想起来,小的时 ...
- PHP常用函数大全。
php usleep() 函数延迟代码执行若干微秒. unpack() 函数从二进制字符串对数据进行解包. uniqid() 函数基于以微秒计的当前时间,生成一个唯一的 ID. time_sleep_ ...
- 最全的PHP常用函数大全
PHP的一些常用函数 quotemeta() 函数在字符串中某些预定义的字符前添加反斜杠. quoted_printable_decode() 函数对经过 quoted-printable 编码后的字 ...
随机推荐
- LightOJ_1038 Race to 1 Again
题目链接 题意: 给一个数n, 每次操作是随机的选择一个[1,N]区间内能够被n整除的数进行除法, 然后得到一个新的n. 问n变成1时的期望操作次数. 思路: 设E[n] 为 当数为x时, 变成 1 ...
- PC硬件之我见——CPU篇
写在最前面: 最近身边很多朋友都购置电脑的想法,往往也会选择性价比较高的DIY攒机方式.不幸的是,并不是所有人都对电脑硬件有一定的了解的,何况在现在这种社会风气下,盲目的相信商家是不明智的.所 ...
- jQuery 表格插件25
jQuery 表格插件可以让你创建各种各样的表格布局,表格布局是报纸和杂志中最常见的布局,现在的网站中也很常见,在这篇文章中,我向大家推荐25个jQuery 的表格插件,你可以任意控制表格的行和列,用 ...
- bzoj 1031: [JSOI2007]字符加密Cipher 後綴數組模板題
1031: [JSOI2007]字符加密Cipher Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 3157 Solved: 1233[Submit ...
- Epoll在LT和ET模式下的读写方式
在一个非阻塞的socket上调用read/write函数, 返回EAGAIN或者EWOULDBLOCK(注: EAGAIN就是EWOULDBLOCK) 从字面上看, 意思是:EAGAIN: 再试一次, ...
- buffer busy waits
Buffer busy waits 当会话想要访问缓冲区中的数据块,而该数据块正在被其他会话使用时将产生Buffer busy waits事件. 其他会话可能正从数据文件向缓冲器读取同样的数据块,或正 ...
- poj2151
求每只队伍都回答出题目,且至少有一只队伍回答出n道题的概率存在性问题我们可以转化为任意性问题用P(每支队伍都回答出题目)-P(每只队伍回答的题目数小于n)然后我们可以递推求解 ..,..,..] of ...
- lambda -- Java 8 find first element by predicate
Java 8 find first element by predicate up vote6down votefavorite I've just started playing with ...
- sql2005如何附加数据库
1.首先把mdf(数据库主文件)和ldf(数据库日志文件)放到C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data 2.登陆sq ...
- hdu 4284 状态压缩
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4284 #include<cstdio> #include<cstring> # ...