PHP无法在URL中识别带有哈希的GET变量

I have a URL like:

http://www.example.com/page.php#tabname

The hash will automatically open a specific tab on the page.

I need to work with a _GET variable, and the URL is like:

http://www.example.com/page.php#tabname?color=red

Then on the page, I have:

echo $_GET['red'];

...but I am getting an undefined index error. How do I get PHP to recognize the variable?

You need to put the query string before the hash:

http://www.example.com/page.php?color=red#tabname

Anything after the hash is not sent to the server. Regardless, you should probably format your url so you send the GET parameters correctly.

http://www.example.com/page.php#tabname?color=red

should be

http://www.example.com/page.php?color=red#tabname