[英]How do I get parameter from hash links in PHP ?
This is my link: http://projects/timp#?period=2014-6-25
这是我的链接:
http://projects/timp#?period=2014-6-25
Obviously this code : 显然这段代码:
$period = $_GET['period']; echo $period;
does not work . 不起作用。 What can i do ?
我能做什么 ?
Change the format of the URLs so that you don't have the #
in the middle. 更改网址的格式,以免中间没有
#
。 It does seem quite weird to have a ?name=value after the #
... 在
#
...之后有一个?name = value似乎很奇怪。
You can't directly get the hash since it won't reach to the server, you can probably do a workaround. 您无法直接获取哈希,因为它不会到达服务器,您可能可以采取解决方法。 Try something like this:
尝试这样的事情:
(Don't forget to append the hash on the url) #?period=2014-6-25
(不要忘记在网址上
#?period=2014-6-25
值) #?period=2014-6-25
<?php
if(isset($_POST['submit'])) {
$hash = $_POST['hash'];
$hash = str_replace(array('#', '?'), '', $hash);
parse_str($hash, $url);
$period = $url['period'];
echo $period; // 2014-6-25
}
?>
<form method="POST">
<input type="hidden" name="hash" value="" />
<input type="submit" name="submit" />
</form>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var hash = window.location.hash;
$('input[name="hash"]').attr('value', hash);
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.