Reply to Re: A general buffering function

Your name:

Reply:


Posted by Michael Placentra II on 04/23/07 21:54

Pass a string, which is the name of the function, and eval() that.

function bufferStuff( $func )
{
ob_start();
eval( "$func();" );
return ob_get_clean();
}

function outputStuff()
{
echo "foo and bar\nand foo";
}

$stuff = bufferStuff( 'outputStuff' );

echo substr( $stuff, 0, 11 );



Note that if you are doing this with your current function (and my
output function):

buffer( outputStuff() );

Then the function outputStuff() is not being passed to your function,
rather it is being run and then the return value of outputStuff() is
being passed to buffer(). I believe that in PHP if you don't use the
return keyword in a function, the return value of the last statement in
the function is returned, so what is really being passed to your
buffer() function is the return value of the last statement in the
function you are trying to pass to it, which may actually be the same
string that is being outputted.

[Back to original 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

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