我有这个网址:
http://www.example.com/get_url.php?ID=100&Link=http://www.test.com/page.php?l=1&m=7
Run Code Online (Sandbox Code Playgroud)
当我打印时$_GET['Link'],我只看到了http://www.test.com/page.php?l=1.
在哪里&m=7?
如果要将URL作为GET参数传递,则必须对其进行URL编码.
问题是,服务器看到&结束Link参数.这意味着你实际上得到了:
$_GET['ID'] = '100';
$_GET['Link'] = 'http://www.test.com/page.php?l=1';
$_GET['m'] = '7';
Run Code Online (Sandbox Code Playgroud)
你想要做的就是使用urlencode.例:
$link = 'http://sample.com/hello?a=5&b=6&d=7';
$address = 'http://site.com/do_stuff.php?link='.urlencode($link)
Run Code Online (Sandbox Code Playgroud)
外部参考: