简体   繁体   English

在PHP中读取哈希参数

[英]read hash parameter in PHP

me jQuery generate url: 我jQuery生成URL:

location.hash = "parameter1=DEF&parameter2=XYZ";
//www.example.com#parameter1=DEF&parameter2=XYZ

How to read this parameter1 and parameter2 in PHP 如何在PHP中读取此parameter1parameter2

Your javascript is client-side and your PHP is server-side, so it's not possible. 您的javascript是客户端,而PHP是服务器端,所以这是不可能的。

You should rethink your application or use Ajax to send data from Javascript to PHP: https://api.jquery.com/jquery.ajax/ 您应该重新考虑应用程序或使用Ajax将数据从Javascript发送到PHP: https : //api.jquery.com/jquery.ajax/

You can by using parse_url 您可以使用parse_url

For eg 例如

$url = 'http://google.com#anchor';

print_r(parse_url($url));

Will give you 会给你

[fragment] = anchor

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM