php 恢复htmlspecialchars
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 恢复htmlspecialchars相关的知识,希望对你有一定的参考价值。
<span style="color: #000000; font-weight: bold;">function</span> restore_hsc<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$len</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">{</span>
<span style="color: #0000ff;">$val</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'&amp;'</span>, <span style="color: #ff0000;">'&'</span>, <span style="color: #0000ff;">$val</span><span style="color: #66cc66;">)</span>;
<span style="color: #0000ff;">$val</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'&ouml;'</span>, <span style="color: #ff0000;">'ö'</span>, <span style="color: #0000ff;">$val</span><span style="color: #66cc66;">)</span>;
<span style="color: #0000ff;">$val</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'&auml;'</span>, <span style="color: #ff0000;">'ä'</span>, <span style="color: #0000ff;">$val</span><span style="color: #66cc66;">)</span>;
<span style="color: #0000ff;">$val</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'&uuml;'</span>, <span style="color: #ff0000;">'ü'</span>, <span style="color: #0000ff;">$val</span><span style="color: #66cc66;">)</span>;
<span style="color: #0000ff;">$val</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'&lt;'</span>, <span style="color: #ff0000;">'<'</span>, <span style="color: #0000ff;">$val</span><span style="color: #66cc66;">)</span>;
<span style="color: #0000ff;">$val</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'&gt;'</span>, <span style="color: #ff0000;">'>'</span>, <span style="color: #0000ff;">$val</span><span style="color: #66cc66;">)</span>;
<span style="color: #0000ff;">$val</span> = <a href="http://www.php.net/str_replace"><span style="color: #000066;">str_replace</span></a><span style="color: #66cc66;">(</span><span style="color: #ff0000;">'&quot;'</span>, <span style="color: #ff0000;">'"'</span>, <span style="color: #0000ff;">$val</span><span style="color: #66cc66;">)</span>;
<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$val</span>;
<span style="color: #66cc66;">}</span>
以上是关于php 恢复htmlspecialchars的主要内容,如果未能解决你的问题,请参考以下文章
php htmlentities和htmlspecialchars 的区别