|
-
May 25th, 2006, 02:21 PM
#1
Thread Starter
Junior Member
ob_start() ??
Hi,
I'm using ob_start() at the top of my script in order to be able to deal with setcookie() ... and at the bottom a wrote ob_flush() .
Will this increase the performance and speed of the website or the opposite ??
Do I need also to add ob_start( 'ob_gzhandler' ) ?
Thanks
-
May 25th, 2006, 04:23 PM
#2
Re: ob_start() ??
Use of an output buffer does not increase the performance of your application. It actually adds an additional layer of processing to your application.
Using an ouput buffer "to be able to" use setcookie() is unecessary and actually bad coding practice. With a well written script, you should never need to use an output buffer in order to use setcookie().
However, controlling when and how your script produces output is sometimes necessary. For example, you may use an output buffer to collect output and discard it, replacing it for alternative output should a fatal error occur. The compression feature provided by the ob_gzhandler function is also another insance where an output buffer is required. The ob_gzhandler function collects the output and uses the gz algorithm to compress the content (where the client supports it) before sending it to the client. This can provide significant bandwidth savings.
-
May 26th, 2006, 12:22 AM
#3
Thread Starter
Junior Member
Re: ob_start() ??
Thanks ..
I'm sure that it is not the best way of coding .. but most of the topics on how to solve setcookie() problem asked to use ob_start() to prevent any output before setcookie() ... do you have any idea how to work without ob_start() ??
-
May 26th, 2006, 12:30 AM
#4
Re: ob_start() ??
Yes, ensure use setcookie before you produce and output.
-
May 26th, 2006, 02:19 AM
#5
Re: ob_start() ??
Output should be the very last thing your script does during its lifetime.
-
May 26th, 2006, 02:27 AM
#6
New Member
Re: ob_start() ??
Also, the output should only contain display logic. No processing
I love pasta 
-
May 29th, 2006, 08:35 PM
#7
Stuck in the 80s
Re: ob_start() ??
If you're mixing output and processing, imagine what would happen if an error occured halfway through the output/processing. You'd get half of the page out, and then an error, which, depending on the application, could end up looking like butt. It's frustrating, and I've run across it in several projects at work.
It's always a good idea to do output after all processing.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|