Reputation: 1537
What is advantages of using ob_start()? What is its effects on performance? Say i have this code:
echo 'hello';
echo 'world';
compare to:
ob_start();
echo 'hello';
echo 'world';
ob_end_flush();
Which one has best performance and why?
Upvotes: 2
Views: 1331
Reputation: 131
The effect on performance is negligible.
Normally PHP renders line by line as instructions are executed. however once you have output buffering turned on by using ob_start()
it means that php will buffer the output and not render it until you hit ob_end_flush()
This is used in case you need to do more processing before sending down the output to the client.
However...
Although output buffering does not affect the performance, you can use it cleverly to increase your website performance. have a look at here
Upvotes: 5