FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » browser url with #...
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: browser url with #... [message #172657 is a reply to message #172653] Wed, 23 February 2011 14:41 Go to previous messageGo to previous message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma:
Senior Member
On 2/23/2011 8:19 AM, Erwin Moller wrote:
> On 2/23/2011 2:02 PM, sheldonlg wrote:
>> On 2/23/2011 4:26 AM, Erwin Moller wrote:
>>> On 2/23/2011 9:47 AM, Vincenzo Scarpa wrote:
>>>> Hi,
>>>>
>>>> with this code I get the address of the browser:
>>>> $url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
>>>>
>>>> but with this address:
>>>> http://www.example.com/example.php#one
>>>>
>>>> the code above does not work ($url contains only 'http://
>>>> www.example.com/example.php').
>>>>
>>>> How come? :(
>>>
>>> Simple, because $_SERVER['REQUEST_URI'] doesn't contain the hash (#).
>>>
>>> A hash is used to point to a certain point in the document.
>>> I am not even sure it is send to the server at all (I think not).
>>>
>>> If you want PHP to know about your #one, send it in the URL like this:
>>>
>>> http://www.example.com/example.php?myInfo=one
>>>
>>> Then from PHP, use superglobal $_GET to fetch the information:
>>> $_GET["myInfo"] <-- will contain 'one'
>>>
>>> You can also combine the Querystring info with a hash:
>>>
>>> http://www.example.com/example.php?myInfo=one#one
>>>
>>> Regards,
>>> Erwin Moller
>>>
>>>>
>>>> Thanks
>>>> Vincenzo
>>>>
>>>>
>>>>
>>>
>>>
>>
>> parse_url will get the stuff after the #.
>>
>
> Hi,
>
> I think parse_url() only works if you feed it an URL that contains the
> hash.
> The problem is that is isn't send to the server at all (I think).
>
> Regards,
> Erwin Moller

Right. I missed that.

--
Shelly
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to call external php script from html?
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 13 07:03:16 GMT 2024

Total time taken to generate the page: 0.03989 seconds