如何使用$ _SERVER获取#post [duplicate]的所有链接或数量

My links are like this

http://sitename.com/test/t9.html#post23

I want to get the full link from the browser, or get only number of the post from it

I've tried:

$_SERVER['SERVER_NAME'];
$_SERVER['REQUEST_URI'];

But this show me only before the hash

http://sitename.com/test/t9.html#post23

i want get all link or the number after hash 23

</div>

The anchor (#) section of the URL is not passed through to PHP, so you'll be unable to get access to it as you're expecting.

You'll need to use javascript to grab it like this:

<script>alert(window.location.hash);</script>

And perhaps then use ajax to send that through to your PHP

$_SERVER['QUERY_STRING']; should actually work i think ;)