FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Output buffering in included file
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Output buffering in included file [message #178727 is a reply to message #178722] Wed, 25 July 2012 09:56 Go to previous messageGo to previous message
Kim Andr Aker is currently offline  Kim Andr Aker
Messages: 17
Registered: September 2010
Karma:
Junior Member
På Tue, 24 Jul 2012 22:07:20 +0200, skrev Dani <dsdani(at)live(dot)com>:

> 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();
> // file content
> ob_end_flush();
> ?>
>
> and in index.php
>
> <?php
> ob_start();
> include('included-file.php');
> ?>

As stated on the manual page http://php.net/ob_start

Output buffers are stackable, that is, you may call ob_start() while
another ob_start() is active. Just make sure that you call ob_end_flush()
the appropriate number of times. If multiple output callback functions are
active, output is being filtered sequentially through each of them in
nesting order.

In essence, you have to use one ob_end_flush() for each ob_start() you
have, or an equal number of ob_end_flush() as you have ob_start(). If you
have ob_start() at the start of your main file or included file, you
should also have an ob_end_flush() at the end of that same file.

--
Kim André Akerø
- kimandre(at)NOSPAMbetadome(dot)com
(remove NOSPAM to contact me directly)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Web page design
Next Topic: ncurses on windows
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Sep 19 01:35:11 GMT 2024

Total time taken to generate the page: 0.05211 seconds