PHP
发布时间:2019-11-12 发布网站:大佬教程 code.js-code.com
大佬教程收集整理的这篇文章主要介绍了php自定义函数转换html标签示例,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
本文实例讲述了php自定义函数转换html标签的方法。分享给大家供大家参考,具体如下:
php;">
php
/*
* Created on 2016-9-29
*
*/
$orig = "I'll \"walk\" the
dog now";
$a = htmlentities($orig
);
$b = html_entity_decode($a
);
echo $a; // I'll "walk" the <b>dog</b> now
echo $b; // I'll "walk" the
dog now
// For users prior to
php 4.3.0 you may do this:
function unhtmlentities($
String)
{
//
replace numeric entities
$
String = preg_
replace('~&#x([
0-9a-f]+
);~ei','
chr(hexdec("\\1"))',$
String
);
$
String = preg_
replace('~&#([
0-9]+
);~e','
chr("\\1")',$
String
);
//
replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES
);
$trans_tbl = array_flip($trans_tbl
);
return strtr($
String,$trans_tbl
);
}
$c = unhtmlentities($a
);
echo $
c; // I'll "walk" the
dog now
?>
运行结果如下图所示:
![php自定义函数转换html标签示例 php自定义函数转换html标签示例](https://files.jb51.cc/file_images/article/201609/2016929115838060.png?201682911593)
更多关于php相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》、《》、及《php常见数据库操作技巧汇总》
希望本文所述对大家php程序设计有所帮助。
大佬总结
以上是大佬教程为你收集整理的php自定义函数转换html标签示例全部内容,希望文章能够帮你解决php自定义函数转换html标签示例所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。