htmlentities() 函数
Definition and Usage
定义和用法
The htmlentities() function converts characters to HTML entities.
htmlentities()函数的作用是:转换字符为HTML字符编码。
Syntax
语法
htmlentities(string,quotestyle,character-set) |
| Parameter参数 | Description描述 |
|---|---|
| string | Required. Specifies the string to convert 必要参数。指定需要解码的字符串对象 |
| quotestyle | Optional. Specifies how to encode single and double quotes. 可选参数。定义如何对单引号和双引号进行编码。 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
<html> <body> <?php $str = "Jane & 'Tarzan'"; echo htmlentities($str, ENT_COMPAT); echo "<br />"; echo htmlentities($str, ENT_QUOTES); echo "<br />"; echo htmlentities($str, ENT_NOQUOTES); ?> </body> </html> |
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 htmlentities($str, ENT_COMPAT, "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>
htmlentities() 函数的更多相关文章
- [PHP]htmlentities() 函数
定义和用法 htmlentities() 函数把字符转换为 HTML 实体. 语法 htmlentities(string,quotestyle,character-set) 参数 描述 string ...
- 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 — 将二进制数据转换成十六 ...
随机推荐
- bzoj 2631: tree 动态树+常数优化
2631: tree Time Limit: 30 Sec Memory Limit: 128 MBSubmit: 1716 Solved: 576[Submit][Status] Descrip ...
- tyvj P1209 - 拦截导弹 平面图最小割&&模型转化
P1209 - 拦截导弹 From admin Normal (OI)总时限:6s 内存限制:128MB 代码长度限制:64KB 背景 Background 实中编程者联盟为了培养技 ...
- nginx的autoindex-目录浏览还有其它两个参数
不知的话,显示的时间是不一定是我们想要的.. http://blog.csdn.net/yuanchao99/article/details/16354163 Nginx打开目录浏览功能(autoin ...
- Android 两个Activity进行数据传送 发送
Activity1:: Intent intent= new Intent(this, OtherActivity.class); String name = "heyiyong" ...
- ? super T ? extends T
? super T ?保存的是 T类型或者T类型的父类 ? extends T ?保存的是 T类型或者T类型的子类
- Android开发详解之onTouch和onClick详解
android组件中的onTouch,onClick,onLongClick事件发生先后顺序和关联: 一,onTouch返回false 首先是onTouch事件的down事件发生,此时,如果长按,触发 ...
- Linux Kernel 'perf_event.c'本地权限提升漏洞
漏洞版本: Linux Kernel 3.11-rc4 漏洞描述: Linux Kernel是一款开源的操作系统 Linux Kernel 'perf_event.c'存在一个安全漏洞,允许本地攻击者 ...
- -_-#【Better Code】throttle / debounce
浅谈javascript的函数节流 javascript函数的throttle和debounce throttle 疯狂触发事件,固定步调执行 debounce 疯狂触发事件,不会执行 var res ...
- HDU-1527 取石子游戏
http://acm.hdu.edu.cn/showproblem.php?pid=1527 交换 :可实现. if( n < m ) { n^=m; m^=n; n^=m; } (三)尼姆博 ...
- [PHP] 跳转以及回到原来的地址
回到原来的地址: 1.PHP(PHP代码) Header('Location:'.$_SERVER["HTTP_REFERER"]); 2.JavaScript(相当于后退按钮,- ...