1

I can do this:

<a href="home.php?var=home">home</a>

But when I have a link with an Id, I can't pass variables:

<a href="home.php#sectionID?var=home">home</a> <--!this doesn't work of course -->

Thanks a lot!

diego
  • 77
  • 1
  • 3
  • 12

3 Answers3

1

When using PHP you can not use '#' in the URL, it will not be passed to the server.

You can use urlencode in order to encode the non-alphanumeric characters.

nbaroz
  • 126
  • 1
  • 5
0

Declare a variable with $home dollar sign, i think you getting confused with JavaScript variable and PHP. To retrieve the variable values on a new page use $_GET['ID'].

Hope this helps.

user1829823
  • 375
  • 2
  • 4
  • 14
0

Use window.location.hash in javascript

<script>alert(window.location.hash);</script>

And the parse_url() function in PHP

<?php echo parse_url("home.php?var=home#sectionID",PHP_URL_FRAGMENT);?>

your HTML will be..

<a href="home.php?var=home#sectionID">home</a>
Sumit Bijvani
  • 8,154
  • 17
  • 50
  • 82