开发者

GET PHP but using # instead of ?=

开发者 https://www.devze.com 2022-12-16 05:08 出处:网络
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 sen

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
0

精彩评论

暂无评论...
验证码 换一张
取 消