How do I use a hyperlink in link variable?

梦想的初衷 提交于 2019-12-11 03:46:16

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!