编码问题,覆盖& amp;到&对于html使用php [英] Encoding issue, coverting & to & for html using php
问题描述
我在html中有一个网址:
I have a url in html:
<a href="index.php?q=event&id=56&date=128">
我需要将其转换为一个字符串:
I need to turn it into a string exactly as:
<a href="index.php?q=event&id=56&date=128">
我知道如何使用preg_replace等,但是在php中有一个函数直接编码,我可以用于其他编码问题,如& nsbp(或任何它是,等)?理想情况下,我会发送我的字符串到函数,它会输出'&'而不是& amp。有转换&TEXT的通用功能;成为一个真正的角色?
I know how to do this with preg_replace etc, but is there a function in php that deals directly with encoding that I can use for other encoding issues such as &nsbp (or whatever it is, etc)? Ideally I would send my string into the function and it would output '&' instead of &. Is there a universal function for converting &TEXT; into an actual character?
编辑:对不起,在我完成输入问题之前发布。 QUESTION现已完成。
sorry, posted this before I finished typing the question. QUESTION is now complete.
推荐答案
$newUrl = html_entity_decode('<a href="index.php?q=event&id=56&date=128">');
echo $newUrl; // prints <a href="index.php?q=event&id=56&date=128">
这篇关于编码问题,覆盖& amp;到&对于html使用php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!