Home > Backend Development > PHP Tutorial > How to convert html tags in php

How to convert html tags in php

巴扎黑
Release: 2023-03-02 15:46:02
Original
1567 people have browsed it

php如何转换html标签,使其能在浏览器中正常显示?
在编程中需要把提交的内容转化成html标签,这样才能在浏览器中正常显示。比如要把'<'转化成'<',把空格' '转换成' '等。
其实php已经有了这样的函数,那就是:html_entity_decode

<?php  
$new = htmlspecialchars("<a href=&#39;test&#39;>Test</a>");  
echo $new; //out &lt;a href=&#39;test&#39;&gt;Test&lt;/a&gt;  
echo html_entity_decode($new); //out <a href=&#39;test&#39;>Test</a>  
?>
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template