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 编码后的字 ...
随机推荐
- linux里的php使用phpize拓展各种功能(curl,zip,gd等等)
这里的实验以拓展zip功能为实例,成功使用zip功能需要如下步骤: 1.下载zip拓展包,并解压,并进入zip文件夹 tar -zxvf zip.tar.gz // 解压 cd zip //进入文件夹 ...
- Bitmap 与Drawable相互转换
Drawable 转 Bitmap import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import ...
- [转载] cookie、JS记录及跳转到页面原来的位置
额....如下 <!-- 定位页面的 Cookie function SetCookie(sName, sValue) { date = new Date(); s = date.getDate ...
- 在QTP中使用DOM
大家对DOM应该都不陌生,它在网页制作中有广泛的应用.如果我们想在QTP中使用DOM模型需要通过Page对象的Object属性来实现.注意,QTP11才有良好的DOM支持操作,这里用百度首页做例子. ...
- bzoj 2286 [Sdoi2011]消耗战(虚树+树上DP)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2286 [题意] 给定一棵树,切断一条树边代价为ci,有m个询问,每次问使得1号点与查询 ...
- 用Delphi直接获取bmp图片的像素
用Delphi直接获取bmp图片的像素,并存储显示出.(此像素主要用在LED上显示).希望高手能给出代码啊!! function getImagePixels(f: string): Integer; ...
- lightoj 1036 dp
题目链接:http://lightoj.com/volume_showproblem.php?problem=1036 #include <cstdio> #include <cst ...
- 宁波Uber优步司机奖励政策(1月25日~1月31日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- Apple Pay强势来袭,开发者应做的事情
"iOS8.1就已经有这个功能了,只是木有现在这么的火,现在的趋势是要火的节奏,因此很多电商平台B2B,P2P,C2C,X2X都有可能需要这个屌丝的付款功能了,在此简单的研究一下." ...
- Apache-POI操作Excel的一些小技巧
Apache-POI操作Excel将合并后的单元格全部填充为相同数据的一个实例. private static void fillMergedRegion(final Sheet sheet) { f ...