这是我的链接:http://projects/timp#?period=2014-6-25
显然这段代码:
$period = $_GET['period']; echo $period;
不起作用。我该怎么办?
答案 0 :(得分:0)
更改网址的格式,以便中间没有#
。在#
...
答案 1 :(得分:0)
您无法直接获取哈希值,因为它无法访问服务器,您可以执行一种解决方法。尝试这样的事情:
(不要忘记在网址上添加哈希值)#?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>