echo parse_url("http://foo?bar#fizzbuzz",PHP_URL_FRAGMENT);
<script>alert(window.location.hash);</script>
<script>$('#LocationHash').val(document.location.hash.replace('#',''));</script>
<input type="hidden" id="LocationHash" name="LocationHash" value="">