Well while you load a page with # tag, php does not know it as # tags on url are treated by basically javascript and are not sent to server. But with a simple AJAX request you can send the value to server on loading the page and get the response through that AJAX response.
To grab the url with Javascript:
var url = document.URL;
And try basename() function to get the last part of the sent url with PHP code.
echo basename( "http://test.com/blog/#segmentIwant" );
Or a simple function in javascript to do it:
var url = document.URL;
hashed_string = url.split("#");
alert(hashed_string[1]);