Page 1 of 1

detecting a " #" and what's after it in PHP

Posted: Fri May 27, 2005 6:42 am
by scriptmaster
Hi

is there a way in a php script (lets say the "myscript.php") to detect if it was called with this url:
http://domain.com/myscript.php#12

or this:
http://domain.com/myscript.php

some kind of server variable I don't know of?

I'm talking about a direct url request of which the $_SERVER['HTTP_REFERER'] is not set.

thank you
P.S: I know I can do this with javascript.

Posted: Fri May 27, 2005 11:04 am
by JAM

Code: Select all

<?php
// http://php.net/manual/en/function.parse-url.php

$array = parse_url('http://forums.devnetwork.net/viewtopic.php?t=33756&something=foo#bar');
print_r($array);
?>

Code: Select all

Array ( 
    &#1111;scheme] =&gt; http 
    &#1111;host] =&gt; forums.devnetwork.net 
    &#1111;path] =&gt; /viewtopic.php 
    &#1111;query] =&gt; t=33756&amp;something=foo 
    &#1111;fragment] =&gt; bar 
)