1
http://xxxx.us/a/6126/securitycheckzpsfc10cc9.jpg#id=558554

I want to Get Url Parameter After Hash.

$hash = $_GET['hash'];

Not Working

I want to Get Url From Address Bar. And Get the Part After Hash.

<?php
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
$url1 = parse_url($url);
echo $url1['fragment'];
?>

This Is Also Not Working.

Johan
  • 85
  • 3
  • 8

2 Answers2

1

Using javascript location.hash, you can change the hash to a GET parameter and send it to your PHP script

<!DOCTYPE HTML>
<html>
<head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</head>
<body>
<a href="http://example.com/?some_parameter=x" class="hashed_link">Link</a>

<script>
    $().ready(function(){
        // navigate to in page anchor for testing
        window.location.href="#hash=12345678";

        // bind anchor click event
        $('.hashed_link').click(function(e){
            e.preventDefault();
            hash_anchor = $(this).attr('href')+'&'+location.hash.substr(1);

            alert(hash_anchor);
            //window.location.href=$(this).attr('href')+location.hash;
        });
    });
</script>
</body>
</html>
0

The hash isn't passed to the server, it is client-side only.

What you are trying to do is not possible, however, it would be possible to get the full URL via Javascript.

You should look into better ways of doing what you want to do. Why don't you pass it as a GET value instead?

Dany Caissy
  • 3,176
  • 15
  • 21