<?php
//定义一个HTML代码字符串
$str=<<<HTM
<a href=#><b><i>到一个网址的链接</i></b></a>
HTM;
$str=htmlentities($str); //将字符串中指定的字符进行转换
echo $str;
?>

PHP中htmlentities和htmlspecialchars的区别:
这两个函数的功能都是转换字符为HTML字符编码,特别是url和代码字符串。防止字符标记被浏览器执行。使用中文时没什么区别,但htmlentities会格式化中文字符使得中文输入是乱码。htmlentities转换所有的html标记,htmlspecialchars只格式化& ' " < 和 > 这几个特殊符号

153-PHP htmlentities函数的更多相关文章

  1. [PHP]htmlentities() 函数

    定义和用法 htmlentities() 函数把字符转换为 HTML 实体. 语法 htmlentities(string,quotestyle,character-set) 参数 描述 string ...

  2. htmlentities() 函数

    Definition and Usage定义和用法 The htmlentities() function converts characters to HTML entities.htmlentit ...

  3. html_entity_decode与htmlentities函数

    htmlentities() 函数把字符转换为 HTML 实体.html_entity_decode() 函数把 HTML 实体转换为字符.例子:$a = '<div> <p> ...

  4. PHP 把字符转换为 HTML 实体 - htmlentities() 函数

    定义和用法 htmlentities() 函数把字符转换为 HTML 实体. 语法 htmlentities(string,quotestyle,character-set) 参数 描述 string ...

  5. php htmlentities()函数 语法

    php htmlentities()函数 语法 作用:把字符转换为 HTML 实体 语法:htmlentities(string,flags,character-set,double_encode) ...

  6. php htmlentities函数的问题

    看到在细说php第二版教程中的函数htmlentities 例子,实际实验没有效果 $str = "一个 'quote' 是<b>bold</b>";ech ...

  7. php常用字符串函数小结

    php内置了98个字符串函数(除了基于正则表达式的函数,正则表达式在此不在讨论范围),能够处理字符串中能遇到的每一个方面内容,本文对常用字符串函数进行简单的小结,主要包含以下8部分:1.确定字符串长度 ...

  8. PHP常用字符串的操作函数

    字符串转换类函数 addcslashes函数:以C语言风格使用反斜线转义字符串中的字符 addslashes函数:使用反斜线引用字符串 chop函数:清除字符串中的连续空格 get_html_tran ...

  9. PHP字符串函数

    php字符串处理函数大全 addcslashes — 为字符串里面的部分字符添加反斜线转义字符addslashes — 用指定的方式对字符串里面的字符进行转义bin2hex — 将二进制数据转换成十六 ...

随机推荐

  1. html弹出框播放视频

    <a data-toggle="modal" data-target=".bs-example-modal-lg">模态框</a> &l ...

  2. php中$_REQUEST、$_POST、$_GET的区别和联系小结

    php中$_REQUEST.$_POST.$_GET的区别和联系小结 作者: 字体:[增加 减小] 类型:转载   php中有$_request与$_post.$_get用于接受表单数据,当时他们有何 ...

  3. asp.net mvc 短信验证码

    把发短信功能写成一个类包,需要引用: SmsUtillity.cs: using System; using System.Collections.Generic; using System.Linq ...

  4. C# DataSet与DataTable的区别和用法 ---转载

    C# DataSet与DataTable的区别和用法 转载:https://www.cnblogs.com/liuyi-li/p/6340411.html DataSet是数据集,DataTable是 ...

  5. AngularJS 官方启动文档

    参考:https://angular.io/guide/quickstart 中文:http://www.angularjs.net.cn/

  6. 标准模板库中的链表(list)

    //C++数据结构与算法(第4版) Adam Drozdek 著  徐丹  吴伟敏<<清华大学出版社>> 头文件:include<list> list() 创建一个 ...

  7. JSON对象和字符串的收发(JS客户端用typeof()进行判断非常重要)

    Ajax前台向后台传递对象: 数据准备 将js对象或者json对象转换为json字符串在Ajax传递,在后台中再将json字符串转换为json对象,再转换为java对象或在前端和后端构造一样的数据结构 ...

  8. netcore webCache缓存

    NetCoreCacheService.dll public IActionResult Index() { //存入字符串 MemoryCacheService.SetChacheValue(&qu ...

  9. html css3

    一.引入样式 1.行内样式表 <h1 style="color: red;font-size: 18px;">10-30</h1> 2.内部样式表(在hea ...

  10. 织梦 dede runphp=yes SQL语句操作

    个人实例dede:channelartlist 下循环出 channel 栏目 中的 文章 {dede:sql sql='select * from dede_arctype where reid = ...