php passing URL
I have this URL:
http://www.example.com/get_开发者_JAVA百科url.php?ID=100&Link=http://www.test.com/page.php?l=1&m=7
When I print $_GET['Link']
, I see only http://www.test.com/page.php?l=1
.
Where is &m=7
?
If you want to pass an url as a GET parameter, you'll have to URL-encode it.
The problem is, the server sees &
as ending the Link
parameter. This means you're actually getting:
$_GET['ID'] = '100';
$_GET['Link'] = 'http://www.test.com/page.php?l=1';
$_GET['m'] = '7';
What you want to do is use urlencode
. Example:
$link = 'http://sample.com/hello?a=5&b=6&d=7';
$address = 'http://site.com/do_stuff.php?link='.urlencode($link)
External references:
- urlencode in PHP
It's a separate value. If you pass it this way, the GET values are:
ID=100
Link=http://www.test.com/page.php?l=1
m=7
The &
character separates values passed by GET.
In order to pass the entire thing, you need to encode it properly (see Sebastian's answer).
(see sebastian's answer).The server sees & as the ending parameter so u won't get the values after &.If u want to get the entire thing u need to encode the entire link using "function urlencode()" before passing the parameters
精彩评论