Home > php教程 > php手册 > php获取URL中带#号等特殊符号参数的解决方法,

php获取URL中带#号等特殊符号参数的解决方法,

WBOY
Release: 2016-06-13 09:26:00
Original
1389 people have browsed it

php获取URL中带#号等特殊符号参数的解决方法,

例如下面的PHP代码:

复制代码 代码如下:


echo $_GET['key'];
?>


当url为http://test.com/c.php?key=999时,正常输出:999
当url为http://test.com/c.php?key=9#888时,只能输出:9
而我想要获得的是9#888,那要怎么办呢?只能在把9#888传递给key的这个环节想办法。

我是用JS中的escape函数编码后传递解决了这个问题,需要的朋友可以参考一下。

复制代码 代码如下:



查询
<script><br /> function searchsn() {<br /> var keys = $('#searchs').val();<br /> if (keys == '') {<br /> alert('请填写SN码');<br /> return false;<br /> }<br /> keys = escape(keys); //对字符串进行编码,* @ - _ + . / 这几个字符除外<br /> window.location.href = 'c.php&#63;key=' + keys;<br /> }<br /> </script>

在PHP中,怎获取上一个页面的URL?

$_SERVER['HTTP_REFERER']
 

php从url获取网页内容

$url = zhidao.baidu.com/question/123456789.html
file_get_contents($url);
 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template