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

Home » Imported messages » comp.lang.php » buffering to allow headers in code?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: buffering to allow headers in code? [message #170172 is a reply to message #170170] Thu, 14 October 2010 20:48 Go to previous messageGo to previous message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma:
Senior Member
.oO(MikeB)

> Michael Fesser wrote:
>>
>> At least partly I have to agree. If this is what your instructor told
>> you:
>>
>> header("Location: index.php");
>>
>> then he might be the wrong one for this job. The above violates the HTTP
>> RFC and can be considered a bug. It also violates conventions for good
>> URLs, because you should never link or redirect to index.* files.
>> Instead you use the directory - that's what these index files are for.
>
> Do you mind explaining this? If I understand you, if my site is
>
> http://localhost/recipes/index.php

The index.php should never appear in any links or redirection URLs. The
better and recommended URL for the above would be

http://localhost/recipes/

> I should code:
>
> header("location: /") ?
>
> or
>
> header("location: localhost/recipes/") ?

Almost. But this still violates the HTTP spec, which _requires_ an
absolute URL for the Location header. So this would be correct:

header('Location: http://localhost/recipes/');

Of course this will be bound to your own local machine, which is not
good. To make it more flexible, replace the 'localhost' part with
$_SERVER['HTTP_HOST']. There are even more examples in the PHP manual.
Just see the page for the header() function for more details.

Micha
[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
Read Message
Read Message
Read Message
Previous Topic: Mesothelioma
Next Topic: Good code or bad code?
Goto Forum:
  

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

Current Time: Sat Nov 30 04:56:31 GMT 2024

Total time taken to generate the page: 0.03878 seconds