473,324 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

What is output buffering in PHP , why should we use it ?

What is the advantage of using output buffering? Why do we need to hold the output from printing in the browser?
Thank you.
Jan 28 '11 #1
5 1999
HaLo2FrEeEk
404 256MB
Headers can't be sent if anything has been output to the browser, using output buffering allows you to get around this. Your output goes to the buffer and you can send your headers even after something has been printed.
Jan 28 '11 #2
Markus
6,050 Expert 4TB
Once output has been sent to the browser, no more headers can be sent. This is sometimes a problem. So, with output-buffering, you can defer the output into a buffer until such time that you deem it OK to send to the browser.
Jan 28 '11 #3
HaLo2FrEeEk
404 256MB
That's what I said, if my answer was right you could have just agreed with it.
Jan 28 '11 #4
Markus
6,050 Expert 4TB
Sorry, HaLo. I had opened this thread before you replied, but then got distracted. By the time I'd posted my reply, you'd already done so, too, though I wasn't aware.
Jan 28 '11 #5
HaLo2FrEeEk
404 256MB
Ah, my apologies, I didn't mean to sound like a jerk, just thought you were trying to steal mah thunda ;)
Jan 28 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mark Evenson | last post by:
A question about Output Buffering in PHP-CLI. Is it expected that the following code will emit two representations of $x? I would like to use print_r(), but capature its output in a String, to...
1
by: lawrence | last post by:
I didn't want blank space getting sent out before session headers or cookies to the web, so I started using ob_start(). When it comes to rendering the page, I wanted to turn it off, so I started to...
1
by: yawnmoth | last post by:
Say I have the following PHP script: <? register_shutdown_function('test'); ob_start(); echo "part2"; function test() { $output = ob_get_contents();
1
by: Tim Mohler | last post by:
All - I have a script that provides a web page interface to various system utilities. Once the user has selected the utility and input various parameters, it calls itself with a different method...
1
by: Shahid Juma | last post by:
Hi, I was wondering if something similar to php (ob_get_contents(), output buffering) exists in ASP/VBscript. Thanks Shahid
4
by: Jon Slaughter | last post by:
I'm using eval to excute some mixed php and html code but I cannot debug it. I am essentially using filegetcontents to load up a php/html file and then inserting it into another php/html file and...
15
by: jools | last post by:
I'm having trouble modifying some code written by someone else. The code is very dense and obscure but does work fine. However I need to insert a block of my own and I've hit what I assume is a...
4
by: Grant Edwards | last post by:
When I ssh in to my Windows XP box and run Python apps, output from "print" and and "sys.stdout.write()" is being buffered so that none of the output shows up until the program exits. From...
11
by: JRough | last post by:
I'm trying to use output buffering to cheat so i can print to excel which is called later than this header(). header("Content-type: application/xmsdownload"); header("Content-Disposition:...
0
by: JRough | last post by:
On Sep 26, 3:23 pm, Captain Paralytic <paul_laut...@yahoo.comwrote: without the exit I get this again: Warning: Cannot modify header information - headers already sent by (output started at...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.