问题
I'm using $_GET['link']
to recieve the link...
but the link has &
's in it causing the variable to be read incorrectly.
How do I do this?
this is the link...
http://vk.com/video_ext.php?oid=172860651&id=162881967&hash=1864975b71a6085a&hd=1
for reference.
Thanks.
回答1:
In writing the link use urlencode
then in reading the link use urldecode
:
<a href="http://example.com/file.php?link=<?php echo urlencode($link);?>">link</a>
<?php
$link = urldecode($_GET['link']);
echo $link;
?>
回答2:
You should use PHP's urlencode (http://php.net/manual/en/function.urlencode.php) when you create the link and and then use urldecode (http://php.net/manual/en/function.urldecode.php) on $_GET['link'] to get the correct value.
来源:https://stackoverflow.com/questions/13663393/how-do-i-use-a-hyperlink-in-link-variable