• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    PHP html_entity_decode()函数讲解

    PHP html_entity_decode() 函数

    实例

    把 HTML 实体转换为字符:

    ?php 
    $str = "lt;copy; W3CSccedil;hdeg;deg;brvbar;sect;gt;"; 
    echo html_entity_decode($str); 
    ?>

    上面代码的 HTML 输出如下(查看源代码):

    !DOCTYPE html> 
    html> 
    body> 
    © W3CSçh°°¦§> 
    /body> 
    /html>

    上面代码的浏览器输出如下:

    © W3CSçh°°¦§>

    定义和用法

    html_entity_decode() 函数把 HTML 实体转换为字符。

    html_entity_decode() 函数是htmlentities() 函数的反函数。

    语法

    html_entity_decode( _string,flags,character-se_ t)

    实例 1

    把一些 HTML 实体转换为字符:

    ?php 
    $str = "Jane  #039;Tarzan#039;"; 
    echo html_entity_decode($str, ENT_COMPAT); // Will only convert double quotes 
    echo "br>"; 
    echo html_entity_decode($str, ENT_QUOTES); // Converts double and single
    quotes 
    echo "br>"; 
    echo html_entity_decode($str, ENT_NOQUOTES); // Does not convert any quotes 
    ?>

    上面代码的 HTML 输出如下(查看源代码):

    !DOCTYPE html> 
    html> 
    body> 
    Jane  #039;Tarzan#039;br> 
    Jane  'Tarzan'br> 
    Jane  #039;Tarzan#039; 
    /body> 
    /html>

    上面代码的浏览器输出如下:

    Jane 'Tarzan' 
    Jane 'Tarzan' 
    Jane 'Tarzan'

    实例 2

    通过使用西欧字符集,把一些 HTML 实体转换为字符:

    ?php 
    $str = "My name is Oslash;yvind Aring;sane. I#039;m Norwegian."; 
    echo html_entity_decode($str, ENT_QUOTES, "ISO-8859-1"); 
    ?>
    
    The HTML output of the code above will be (View Source):
    
    !DOCTYPE html> 
    html> 
    body> 
    My name is Øyvind Åsane. I'm Norwegian. 
    /body> 
    /html>

    上面代码的浏览器输出如下:

    My name is Øyvind Åsane. I'm Norwegian.

    总结

    以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对脚本之家的支持。如果你想了解更多相关内容请查看下面相关链接

    您可能感兴趣的文章:
    • PHP微信发送推送消息乱码的解决方法
    • PHP删除数组中特定元素的两种方法
    • PHP实时统计中文字数和区别
    • PHP正则判断一个变量是否为正整数的方法
    • PHP正则验证字符串是否为数字的两种方法并附常用正则
    • PHP判断是否是微信打开还是浏览器打开的方法
    • asp函数split()对应php函数explode()
    • PHP htmlentities()函数用法讲解
    • PHP hex2bin()函数用法讲解
    • PHP中rename()函数的妙用讲解
    上一篇:PHP hex2bin()函数用法讲解
    下一篇:PHP htmlentities()函数用法讲解
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    PHP html_entity_decode()函数讲解 PHP,html,entity,decode,函数,