473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Is it possible to get the full url using php, url with an hash?

67
Hi guys

I am trying to get the full url of a page using php. The url looks like ->

http://www.example.com/list.php?type=event&p=5|14#2

The issue is, I am getting everything except the part after the hash (#). Anyone knows a way to get the full url, including the part with the #, #2 in this example?

thanks for your time guys. If I get a solution, I'll post it back. :)
Nov 10 '07 #1
7 28137
Atli
5,058 Expert 4TB
Hi.

As far as I know, it isn't possible.
Only thing my research into this matter turned up was that the anchors are only ever used client-side, so there would be no real reason for a server-side language to read them.

If you find anything more on the subject, please share it with us.
Nov 10 '07 #2
kigoobe
67
Thanks Atli. Actually, php can indeed 'read' the component after #. The problem is getting it. I mean, you can easily do -

[PHP]$url = parse_url('http://www.example.com/list.php?type=event&p=5|14#2');
print $url['fragment'];[/PHP]

-to get the part after this #.

Logically, if php can read this if supplied directly, why it shouldn't be able to fetch it. In real life, we need a solution like -

[PHP]$url = parse_url($_SERVER['REQUEST_URI']);
print $url['fragment'];[/PHP]

Hmmm ... :(
Nov 10 '07 #3
Atli
5,058 Expert 4TB
True, PHP can indeed manipulate pretty much any string into whatever form you like, but only if we can obtain the string.

Which highlights our problem so far. I have yet to discover a method of "reading" the anchor data into a PHP variable from the URL requested by the client.

As you say, it would be ideal if the server could parse this into the $_SERVER array just like it does the rest of the URL.
Nov 10 '07 #4
kigoobe
67
yes Atli, it's strange (I find) that php doesn't do it (?). Anyway, for the moment, I am changing my urls from # to *. That would solve the issue here.

However, here I am doing a workaround, much longer, which could have been easier if we could get that through the $_SERVER array.

php6 ... ???
Nov 10 '07 #5
Atli
5,058 Expert 4TB
I don't know if this will change in PHP6. Doubt it.

But what, if I may ask, are you doing that requires you to read the anchors?
Nov 10 '07 #6
kigoobe
67
Actually I was looking for a php (multilevel) tree menu. The aim is to create something that will have some menus open by default, rest open or close as we click on them. I looked around much, and found finally http://phplayersmenu.sourceforge.net/demo.php. This looks fine, and here we can get the current menu (the last menu item that has been clicked) as #$menu_id.

I wanted to modifiy this to highlight the last clicked menu. This could be done if I could catch the #id ... that's why. There must be other solutions as well ... but ...

The other way is to go for a javascript based menu ... but I am afraid for browsers that do not support javascript or where javascript is turned off !!! :(
Nov 10 '07 #7
Atli
5,058 Expert 4TB
Ahh, I see.

I did something like this a while ago. I used a cookie to store the ID's of the open menus.

If I remember correctly, I echoed a name and an URL for each menu item into a Javascript array. Then when ever a user opened or closed a menu, I would fetch the relevant data from the array to show the menus and save the ID's of the menu in a cookie using Javascript.

So yea, mine would probably be a Javascript phenomena :P

But the cookie idea isn't bad. It clears the query string of all the extra data and you have much more control over it.
Nov 11 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jean-Guillaume Paradis | last post by:
Hi, I've tried to use the md5 module of python 2.3.3, and the results of a hash do not concord with those of reference sites such as http://bfl.rctek.com/tools/?tool=hasher I call it using ...
5
by: Nathan Sokalski | last post by:
I need to get the full URL of the current page in ASP. When using Request.ServerVariables("URL") anything after the filename (such as a #section1 to jump to an area on the page or data submitted...
1
by: Martijn van Oosterhout | last post by:
Today I got the error: ERROR: FULL JOIN is only supported with mergejoinable join conditions Which is really annoying since a full join is exactly what I wanted. I guess the alternative is to...
8
by: Daniel | last post by:
Hi, Does anyone know if it is possible to put an aspx page inside of another? OR run an aspx page and capture the output as a string and then write this out to a page.... So for example say...
12
by: Arash Partow | last post by:
Hi all, I've ported various hash functions to python if anyone is interested: def RSHash(key): a = 378551 b = 63689 hash = 0
28
by: beach.dk | last post by:
Hi, I'm trying to implement a simple hash algorith called rs_hash in javascript, but I cannot get a correct result. In c the code looks like this:
2
by: Paulo da Silva | last post by:
Hi. I have a class Foo with a string. I want to store its elements in a hash_set beeing the hash executed over the string. How do I do that? class Foo { ... string s; ...
1
by: codferrow | last post by:
Hello, I have a small issue with a web-search engine I'm working on. The main table is constantly growing (1 insert per second, currently 150 000 records) and it has full-text indexes on 2 fields...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.