替换rawurlencode中的实体,即& lt; & gt; & quot; [英] replace entites in rawurlencode i.e. < > "
问题描述
我有以下代码
<a href="snippet:add?code=<?php echo rawurlencode($snippet->snippet_content); ?>Save snippet</a>
其中
'$snippet = <a rel="nofollow" href="http://digg.com/submit?phase=2&url=<?php the_permalink(); ?>" title="Submit this post to Digg">Digg this!</a>'
如何获取rawurlencode替换& lt";到<"?
How could I get rawurlencode to replace "<"; to a "<"?
非常感谢
rob
已更新
使用
<?php echo rawurlencode(html_entity_decode($snippet->snippet_content)); ?>
如下面的海报所建议,谢谢您解决了更改& lt;的问题.改为<"但在整个代码段中插入\\
as suggested by the posters below, thankyou fixes the changing < ; to "<" but inserts \ throughout the snippet
<a rel=\"nofollow\" href=\"http://delicious.com/post?url=<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>\" title=\"Bookmark this post at Delicious\">Bookmark at Delicious</a>
我要查找的输出也没有反斜杠
the output I'm seeking is without the backslashes aswell
<a rel="nofollow" href="http://delicious.com/post?url=<?php the_permalink(); ?>&title=<?php echo urlencode(get_the_title($id)); ?>" title="Bookmark this post at Delicious">Bookmark at Delicious</a>
欢呼抢劫
已修复
感谢所有发布者!
<?php echo rawurlencode(htmlspecialchars_decode(stripslashes($snippet->snippet_content))); ?>
发挥魅力,
非常感谢抢劫
推荐答案
rawurlencode()
与html-encoding转换无关.它执行URL编码.要解码的匹配函数是 rawurldecode()
,但同样,不是您在这里寻找的东西.
rawurlencode()
has nothing to do with converting to/from html-encoding. It performs URL encoding. The matching function to decode is rawurldecode()
, but again, that is not what you're looking for here.
<
编码是html编码.为此,您需要 html_entity_decode()
解码或 htmlentities()
进行编码.
The <
encoding is html-encoding. To handle that, you want html_entity_decode()
to decode or htmlentities()
to encode.
上述功能的基本用法是:
Basic usage for the above sets of functions is:
$urlEncodedStr = rawurlencode($str);
$urlDecodedStr = rawurldecode($str);
$htmlEncodedStr = htmlentities($str);
$htmlDecodedStr = html_entity_decode($str);
要将它们组合在一起,可以进行一些组合:
To combine them together you would do some combination:
$urlEncodedHtmlDecodedStr = rawurlencode(html_entity_decode($str));
这篇关于替换rawurlencode中的实体,即& lt; & gt; & quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!