How to get data off of the links?

Need to get the id parameter from the link: www.domen.ru/test.php#id=123

Know how to do it if GET, but what then?

I found only this:parse_url, but it is not clear how to transfer the link.
July 9th 19 at 11:22
3 answers
July 9th 19 at 11:24
Solution
July 9th 19 at 11:26
explode + parse_str

ps.
If you get it from the links refers to the hash of the currently open page, it is not to PHP.
and as for the entrance itself, the url is given? - Otha_Beahan commented on July 9th 19 at 11:35
it is possible an example? - Otha_Beahan commented on July 9th 19 at 11:29
: in the documentation. explode on the grill. The resulting second part parsim using parse_str, it turns out the array with all that is necessary. - bailee_Stant commented on July 9th 19 at 11:32
I will go if just when you go to the page the link will be displayed on the screen, is that possible? - Otha_Beahan commented on July 9th 19 at 11:38
: I have a problem is not the parsing, and generating links - Otha_Beahan commented on July 9th 19 at 11:44
well, with PHP it does not get if you want it, I once wrote about it.

To need using JS then, and then transfer to PHP, or immediately withdraw. - bailee_Stant commented on July 9th 19 at 11:47
July 9th 19 at 11:28
Is it in $_SERVER{'REQUEST_URI'} is present information after '#'?
Or where did you get this link.
this redirect after login, is it possible to just bring the link via echo? - Otha_Beahan commented on July 9th 19 at 11:31
Above you write "my problem is not the parsing, and generating links".
To be honest I don't really understand what your situation is.
Who where and as directed is unclear. - bailee_Stant commented on July 9th 19 at 11:34
:I need to get the address of the page on which I am at the moment - Otha_Beahan commented on July 9th 19 at 11:37
: alert(window.location.href); - Otha_Beahan commented on July 9th 19 at 11:40
With php, probably nothing.
Parameter right of the "#" to the server is not transmitted.
You need to connect the javascript to take the window.location.href and then have options.
For example, it is possible to do a redirect test.php#id=123 -> test.php?id=123 - bailee_Stant commented on July 9th 19 at 11:43
: could you tell me how to just write to a file on the server using alert(window.location.href);? - Otha_Beahan commented on July 9th 19 at 11:46
use jQuery or pure javascript? - bailee_Stant commented on July 9th 19 at 11:49
: Node.js - Otha_Beahan commented on July 9th 19 at 11:52
In General, if I understand correctly, the code on the page like this:
var myurl = '/my-save-script.php';
var link = location.href;
var params = link.substr(link.indexOf('#')+1);

var s = document.createElement('script');
s.src = myurl + '?' + params;
document.getElementsByTagName("head")[0].appendChild(s);

it connects the script to the address my-save-script.php and transfers it by the method GET parameters after "#".
In the file my-save-script.php you get in $_GET is all the parameters, and do with them what you want.
But I have a suspicion that I not that you have suggested over have surfaced node.js - Daphne_Roob commented on July 9th 19 at 11:55
: Thanks! - Otha_Beahan commented on July 9th 19 at 11:58

Find more questions by tags APIPHP