When using the $_GET[] in php, it searches for a var开发者_如何学Ciable e.g ?id=value
Is there a way to call the #value instead?
No, because the hash part of the url is client-side only and is not sent to the server.
When you enter an URL such as http://server.com/dir/file.php?a=1#something
in your browser's URL textbox, the browser opens a connection to the server.com
and then issues a HTTP command GET /dir/file.php?a=1 HTTP/1.1
. This is the only data sent to the server.
Hence, the server never gets the #something
part, and this means there is no script on server side you could write to read that value.
Similar question explained here: How to get Url Hash (#) from server side
I've been able to work around it by getting the fragment via javascript and sending an ajax request with the fragment as the $_GET contents.
Without knowing your whole case, I may be off track, but there is the possibility of sending the #something to the server via a simple GET type of xmlhttprequest.
Yeah there is a way. I think what you want to do is:
$arValues = array_values($_GET);
// whatever else you want to do with the values
精彩评论