I am trying to echo the hash at the end of the URL.
This didn't work
<?php
echo '<script type="text/javascript">
$(this).hash.substring(1);</script>';?>
Any ideas?
Try location.hash.substring(1) instead:
echo '<script type="text/javascript">
var fragment = location.hash.substring(1);</script>';
Note that this PHP code does only echo HTML and JavaScript code to get that fragment value. PHP itself cannot retrieve that part of the URI as it is not part of the requested URI but only locally available.
It looks like you're trying to combine two languages, but I don't think it's possible to do what you want this way. At a guess, you're trying to get the "#hashbit" from a url like this:
http://www.example.com/page.php?something#hashbit
Unfortunately, the browser doesn't send the "#hashbit" to the server. It's only used on the client side. You could write some JavaScript to grab the "#hashbit" to the server separately.
this variable.
$(this)refers to in your code?