是否可以对包含url编码的url的urlencode? [英] Is it possible to urlencode a url that contains a url encoded url?

查看:131
本文介绍了是否可以对包含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'))

这篇关于是否可以对包含url编码的url的urlencode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆