In JavaScript, unless you've got something else going on, you should be able to get the full URL from document.location, (so var URLstring = document.location; for example).
In PHP, as others have noted, this is impossible due to the way the hash works (it navigates within the page, and does not trigger a page-reload so the server never knows about it, unless the JS calls an Ajax function that triggers a script on the server).