是否可以对包含url编码的url的urlencode?
我有一个使用Facebook,Twitter,美味共享链接的网站.它们包含您要共享的网站的url编码的url.问题是我然后想通过php重定向页面发送facebook/twitter/delicious url.
I have a website that uses the facebook, twitter, delicious share links. They contain a a url encoded url of the website that you wish to share. The problem is I then want to send the facebook/twitter/delicious url through a php redirect page.
在已编码的网址中对网址进行编码会起作用吗?会不会有副作用?
Will it work to encode a url within an encoded url? Will there be side effects?
为简化我的问题:
www.website.com/redirect.php?url=" URLENCODED (http://www.facbook.com/sharer.php?t='URLENCODED(title)'&u='URLENCODED(http://www.hotel.com)')
您可以使用百分比编码对字符串进行多次编码,并通过将其解码相同次数来获得原始值:
You can encode a string multiple times with the percent encoding and get the original value by decoding it the same amount of times:
$str = implode(range("\x00", "\xFF"));
var_dump($str === urldecode(urldecode(urldecode(urlencode(urlencode(urlencode($str)))))));
此处,$str
的值被编码3次,然后解码3次.重复编码和解码的输出与$str
的值相同.
Here the value of $str
is encoded three times and then decoded three times. The output of that repeated encoding and decoding is identical to the value of $str
.
所以尝试一下:
'http://example.com/redirect.php?url='.urlencode('http://www.facbook.com/sharer.php?t='.urlencode('title').'&u='.urlencode('http://www.hotel.com'))