4

次のコードがあります

<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)); ?>

以下のポスターで示唆されているように、変更を修正していただきありがとうございます < ; "<" に変更しますが、スニペット全体に \ を挿入します

<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))); ?>

魅力的に働き、

どうもありがとうロブ

4

2 に答える 2

3

rawurlencode()html エンコーディングとの変換とは関係ありません。URL エンコードを実行します。デコードするマッチング関数は ですがrawurldecode()、これはここで探しているものではありません。

&lt;エンコーディングは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));
于 2010-08-14T13:13:59.350 に答える
2

関数を使用してhtml_entity_decode()&lt;a toをエスケープする必要があります<

rawurlencode()ただし、これは URL 引数であるため、後で呼び出す必要があります。

<?php echo rawurlencode(html_entity_decode($snippet->snippet_content)); ?>
于 2010-08-14T13:10:16.777 に答える