本文介绍了如何在链接变量中使用超链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 $ _ GET ['link']
来接收链接...
但该链接中有&
',导致变量被错误地读取。
我该怎么做?
这是链接...
仅供参考。
谢谢。
解决方案
在编写链接时使用 urlencode
然后在阅读链接时使用 urldecode
:
< a href =http://example.com/file.php?link=<?php echo urlencode($ link);?>>链接< / a>
<?php
$ link = urldecode($ _ GET ['link']);
echo $ link;
?>
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.
解决方案
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;
?>
这篇关于如何在链接变量中使用超链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!