Ivošš
Ivošš

Reputation: 1146

read hash parameter in 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

Upvotes: 0

Views: 91

Answers (2)

Raheel
Raheel

Reputation: 9024

You can by using parse_url

For e.g

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

print_r(parse_url($url));

Will give you

[fragment] = anchor

Upvotes: 1

PJ Bergeron
PJ Bergeron

Reputation: 2998

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/

Upvotes: 1

Related Questions