-1

i write < ? php

if(isset($_REQUEST['id'])){

echo $_REQUEST['id'];

} ? >

< a href="#id=3" > click < /a >

But I didn't get the value of id.. How can i get it?

3 Answers3

1

I don't think you can do it since the string after # is interpreted by the browser as anchor name so it'll not being passed to the server.

Felix
  • 37,892
  • 8
  • 43
  • 55
0

You cannot do that with php, because the value after hash cannot send to server. You can use js to send it to server like;

var hash = window.location.hash;

$.get("get_hash.php?hash=" + hash, function(response) {
    // handle response
});

in get_hash.php:

$hash = $_GET['hash']; //#id=4
$remove_hash = substring($hash, 1, strlen($hash) - 1); //id=4
$id_arr = explode("=", $param_arr[1]); // 0=> id, 1=> 4
echo "id=" . $id_arr[1]; // 4
Hüseyin BABAL
  • 15,400
  • 4
  • 51
  • 73
  • i write click but here were errors, Notice: Undefined index: page in H:\xampp\htdocs\upload\hi.php on line 3 Fatal error: Call to undefined function eplode() in H:\xampp\htdocs\upload\hi.php on line 4 –  Feb 06 '14 at 07:03
  • @Harry, you cannot get hash value on server side, you need to send value after hash by using javascript. I have provided you quick example – Hüseyin BABAL Feb 06 '14 at 07:07
-1

Try this for getting the value of last parameter.

$url = "localhost/gft/wp-admin/admin.php?page=abc-yu#id=4";

$last = end(explode("=",$url));

echo $last;
Jenz
  • 8,280
  • 7
  • 44
  • 77