Forum Moderators: coopster
Unfortunately $HTTP_SERVER_VARS["QUERY_STRING"] doesn't work with hashes "#"
Thus an url such as
http://www.abc.com/def.htm#ghi
parses as
http://www.abc.com/def.htm
and the anchor pointer "ghi" gets lost.
I want to read "ghi" into a php variable and save it into a cookie. How can this be done?
Thank you very much for any input.
[edited by: jatar_k at 12:11 am (utc) on Jan. 28, 2004]
[edit reason] delinked [/edit]
$_SERVER['PHP_SELF']
$_SERVER['argv']
print '<pre>';
print_r($_SERVER);
print '</pre>';
print '<pre>';
print_r($HTTP_SERVER_VARS);
print '</pre>';
I just tested this as you are describing it and I understand what you are getting at now. I created a simple page with an
<a href="http:://mysite.com/test.php#shopping">Shopping</a>
test.php script I dumped all the variables to see what was available. Plenty! But no anchor name! Leads me to wonder if this isn't an HTTP server configuration or directive that needs to be set. Anyone?
Getting anchor from URL [webmasterworld.com]
There is a statement in there by a respected member of the WebmasterWorld community that the anchor name never leaves the browser.
What perplexes me is how does it show up in the address bar of my browser once the test.php script is executed and returns the HTML? I mean, really, if the anchor name never left the browser, where does the browser get the value to be displayed? It must be retained and managed by the user agent. I wonder where we could find supporting documentation for this theory?
Also, I found some supporting documentation. Although this property does not appear in the
W3 DOM specification [w3.org] for the A [w3.org] element, it is my understanding it is present in modern browsers for backward-compatibility. The hash property navigates to the named anchor without reloading the document.
RFC 1738 [rfc-editor.org] is the reference for complete information about the hash. It has been updated by:
RFC1808 [rfc-editor.org], RFC2368 [rfc-editor.org], RFC2396 [rfc-editor.org]
The authoritative source for such information is the relevant RFC 2396.
Specifically, you should read section 4.1, which reads:
When a URI reference is used to perform a retrieval action on
the identified resource, the optional fragment identifier,
separated from the URI by a crosshatch ("#") character, consists
of additional reference information to be interpreted by the user
agent after the retrieval action has been successfully completed.
As such, it is not part of a URI, but is often used in
conjunction with a URI.Thus, we can conclude that browsers do not send the fragment
identifier to the server. Instead they keep it, and apply it after
the resource has been sent to them. Of course, to be of any use
whatsoever, the identified fragment must be defined within that
resource.