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 #170168 is a reply to message #170166] Thu, 14 October 2010 15:16 Go to previous messageGo to previous message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma:
Senior Member
.oO(MikeB)

> Jerry Stuckle wrote:
>> On 10/14/2010 9:39 AM, MikeB wrote:
>>>
>>> Thanks for any advice.
>>
>> Get a new instructor.
>
> Wow, (or as we used to say: yes, well, no fine).

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.

But for your problem - you should restructure your code. Put the login
routines first, then all the stuff that depends on it.

> But I assume from your advice that it is a bad suggestion he made?

Yes.

> Even
> though PHP clearly allows for using output buffering and even rearranges
> the output to put the headers first in the output buffer?

OB has its uses, but not for fixing problems caused by an improper code
structure.

See it this way: Before your header() call, your code already has done a
lot of things, even built a navigation bar. And for what? For nothing.
Completely useless work. If you restructure your code, you don't need
this redirect anymore.

In short: Keep the business logic before any presentation logic.

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: Wed Nov 27 09:59:26 GMT 2024

Total time taken to generate the page: 0.04814 seconds