在PHP中读取哈希参数

问题描述:

me jQuery generate url:

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

How to read this parameter1 and parameter2 in PHP

me jQuery generate url: p>

  location.hash =“  parameter1 = DEF& parameter2 = XYZ“; 
 // www.example.com#parameter1 = DEF& parameter2 = XYZ 
  code>  pre> 
 
 

如何阅读 PHP中的parameter1 strong>和 parameter2 strong> p> div>

Your javascript is client-side and your PHP is server-side, so it's not possible.

You should rethink your application or use Ajax to send data from Javascript to PHP: https://api.jquery.com/jquery.ajax/

You can by using parse_url

For e.g

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

print_r(parse_url($url));

Will give you

[fragment] = anchor