You are here: Re: [PHP] Multiple callback_outputs for ob_start « PHP « IT news, forums, messages
Re: [PHP] Multiple callback_outputs for ob_start

Posted by Jochem Maas on 12/08/05 14:44

Chris Shiflett wrote:
> Mathijs wrote:
>
>> How can i add more callback_outputs to ob_start?
>>
>> I want to have both: ob_start('switchContent');
>> and: ob_start('ob_gzhandler');
>
>
> I don't think you can, but you could have a single function that calls
> both, then specify that function in ob_start().

I think you can by simply stacking multiple output buffers on top
of each other:

ob_start('switchContent'); // first buffer, for first callback
ob_start('ob_gzhandler'); // second buffer, for second callback

take care to define the handlers in the 'right' order
(the order that they are run in may be important to your output/code)

// rest of code.

I implemented a class once that stacks a list of callbacks
which could then all be run by its callback handler, psuedo-code:

class CB
{
private static $cbs = array();

public static function addCB($cb)
{
if (is_callable($cb)) {
self::$cbs[] = $cb;
}
}

public static function run($data)
{
foreach (self::$cbs as $cb) {
$data = call_user_func($cb, $data);
}

return $data;
}
}

ob_start( array('CB','run') );

>
> Chris
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация