gpt4 book ai didi

php - 替换 rawurlencode 中的实体,即 < >“

转载 作者:可可西里 更新时间:2023-10-31 22:59:34 25 4
gpt4 key购买 nike

我有以下代码

<a href="snippet:add?code=<?php echo rawurlencode($snippet->snippet_content); ?>Save snippet</a>

在哪里

'$snippet = &lt;a rel=&quot;nofollow&quot; href=&quot;http://digg.com/submit?phase=2&amp;url=&lt;?php the_permalink(); ?&gt;&quot; title=&quot;Submit this post to Digg&quot;&gt;Digg this!&lt;/a&gt;'

我怎样才能得到 rawurlencode 来替换 "<";到一个“<”?

提前致谢

抢劫

已更新

使用

<?php echo rawurlencode(html_entity_decode($snippet->snippet_content)); ?>

正如下面的海报所建议的,thankyou 修复了不断变化的 < ;到 "<"但在整个片段中插入\

<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>

我正在寻找的输出也没有反斜杠

<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 编码无关。它执行 URL 编码。要解码的匹配函数是rawurldecode() ,但同样,这不是您要查找的内容。

< 编码是 html 编码。要处理这个问题,您需要 html_entity_decode()解码或htmlentities()进行编码。

以上几组函数的基本用法是:

$urlEncodedStr  = rawurlencode($str);
$urlDecodedStr = rawurldecode($str);
$htmlEncodedStr = htmlentities($str);
$htmlDecodedStr = html_entity_decode($str);

要将它们组合在一起,您需要进行一些组合:

$urlEncodedHtmlDecodedStr  = rawurlencode(html_entity_decode($str));

关于php - 替换 rawurlencode 中的实体,即 < >“,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3483422/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com