Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #6651

Re: Output buffering in included file

Path csiph.com!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: Output buffering in included file
Date Wed, 25 Jul 2012 07:33:06 +0200
Lines 33
Message-ID <a79eojFnn7U1@mid.individual.net> (permalink)
References <61c7743a-3a40-4465-b8a0-47acb31b6628@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net NN+rxhP8TzyK2NRU9vFBBgiYJEfGDCXeI+f59BEb5LtClR5OUnDrg3PEgY7OcF64/7
Cancel-Lock sha1:sf2FjdZCSe1O21QRLoCdMvtsHG0=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120613 Firefox/12.0 SeaMonkey/2.9.1
In-Reply-To <61c7743a-3a40-4465-b8a0-47acb31b6628@googlegroups.com>
Xref csiph.com comp.lang.php:6651

Show key headers only | View raw


Dani wrote:
> Hello everybody,
> instead of using (e.g. in index.php)
>
> <?php
> ob_start();
> include('included-file.php');
> $output = ob_get_clean();
> echo $output;
> ?>
>
> to store the output buffer into a variable, can I use in included-file.php
>
> <?php
> ob_start();
> include('included-file.php');
> ?>

You can do all of it in the include file, but everything which is before/after 
the include file will not be in the buffer.

Remember also that pages which takes long time to generate, may cause time 
outs when using buffers. IMHO don't use buffers if you really don't have a 
good reason to use them, just see to that you have proper error handling and 
your functions returns the generated content instead of using echo/print.
Those times you have a area where you know there will be issues of long 
execution time, just see to generate some output once in a while.



-- 

   //Aho

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Output buffering in included file Dani <dsdani@live.com> - 2012-07-24 13:07 -0700
  Re: Output buffering in included file "Peter H. Coffin" <hellsop@ninehells.com> - 2012-07-24 15:42 -0500
    Re: Output buffering in included file Dani <dsdani@live.com> - 2012-07-25 02:31 -0700
  Re: Output buffering in included file "J.O. Aho" <user@example.net> - 2012-07-25 07:33 +0200
    Re: Output buffering in included file Dani <dsdani@live.com> - 2012-07-25 02:41 -0700
      Re: Output buffering in included file "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-07-25 12:00 +0200
  Re: Output buffering in included file Kim André Akerø <kimandre@nospambetadome.com> - 2012-07-25 11:56 +0200
  Re: Output buffering in included file Jerry Stuckle <jstucklex@attglobal.net> - 2012-07-25 08:39 -0400
    Re: Output buffering in included file Dani <dsdani@live.com> - 2012-07-25 06:31 -0700
      Re: Output buffering in included file "J.O. Aho" <user@example.net> - 2012-07-25 17:51 +0200
      Re: Output buffering in included file "Peter H. Coffin" <hellsop@ninehells.com> - 2012-07-25 10:43 -0500
        Re: Output buffering in included file Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-07-25 18:44 +0200

csiph-web