Jump to content

PHP5 Problem?


Drezard

Recommended Posts

Hey I'm wondering with these scripts (http://evolt.org/PHP-Login-System-with-Admin-Features) here how does the Header() function supposed to work? It seems like everyone likes to set cookies and send headers in the middle of there script. Now, did this work in PHP4 or do I need some PERL or Add-on so I can send headers and such. I know u have a FAQ all about this. It just makes no sense about how to fix the problem. Its only a diagnostic.

 

Okay, Please explain...

 

Cheers, Daniel

Link to comment
Share on other sites

You can output headers with Header() as long as you have not yet produced any other output.  Same with cookies.  If it's not working, you need to find where the output has already been produced.

 

You haven't explained what you are trying to do and what is going wrong.

Link to comment
Share on other sites

You can output headers where ever you like if you use ob_start and ob_end_flush.

 

I used to reserve these for building my cms's as not so many would be in the cms for long periods so I thought it would not matter about server load and runtime etc.  I read an article recently that suggest that if you have lots of output statements all over (echo, print_r etc.) using the output buffer can actually reduce the processing time of the script significantly.  I did a little benchmarking and my results agreed - even on a fairly small script that didn't do too much...

Link to comment
Share on other sites

You can output headers where ever you like if you use ob_start and ob_end_flush.

 

I used to reserve these for building my cms's as not so many would be in the cms for long periods so I thought it would not matter about server load and runtime etc.  I read an article recently that suggest that if you have lots of output statements all over (echo, print_r etc.) using the output buffer can actually reduce the processing time of the script significantly.  I did a little benchmarking and my results agreed - even on a fairly small script that didn't do too much...

That's a code smell. You should not rely on this.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.