php: how to get a word hash from the url of the current page

I've been developing a mixitup filtering that includes support for URL hashing in WordPress. But one of the tasks, I need to recover the subsequent hash word and pass it to the pure php string as a variable. Like I have this url and I want to get that "# slug_1" only.


I have tried with the following javascript code to capture the word hash and I have passed it to php as the following format.

    <? php $ hash_value = "";

After that, the hash value stored in that php variable but did not work in any html tag within which there was another quote in the container of this variable. He showed the direct script there.

                <a href = ""> Something

So, my question is, how can I reach that value in order to use it anywhere with php?

If I have to use ajax to get that value, then could someone tell me briefly about this process because I'm doing all this as a short code and also from the function file?

Thank you