$_SERVER['REQUEST_URI'] with #hash too?

2019-02-17 19:01发布

If i request site/page.php#hash the $_SERVER['REQUEST_URI'] is only /page.php.

Is there a way to know in php (without later ajax) that the user requested the page with #hash?

Thanks

2条回答
可以哭但决不认输i
2楼-- · 2019-02-17 19:30

Short answer: No.

The hash isn't passed to the server, it exists only on the client-side. This is by design. If the solution to your problem involves needing to know the hash server-side, you've chosen the wrong way to go about it.

查看更多
放荡不羁爱自由
3楼-- · 2019-02-17 19:47

Why don't you use php's $_GET method (instead of using hash(#))?

if(isset($_GET['hash'])){/*do something*/}

The # is only on the client side and php cannot access it.

查看更多
登录 后发表回答