On Sat, 2009-05-23 at 14:43 +0100, Stuart wrote:
> 2009/5/23 Afan Pasalic <[email protected]>:
> > short hack works like a charm!
> > :-)
>
> It may work but output buffers are relatively expensive. The eval
> function will return the value the eval'd code returns, so just stick
> a return statement at the end of the string you're eval'ing.
Where di you hear that output buffers are expensive? I have found the
following:
<?php
ob_start();
for( $i = 0; $i < 10000000; $i++ )
{
echo 'blaaaaaaaaaaaaaaaaaaaaaaaaaah';
}
$foo = ob_get_contents();
ob_end_clean();
?>
To consistently be faster than the following:
<?php
for( $i = 0; $i < 10000000; $i++ )
{
$foo .= 'blaaaaaaaaaaaaaaaaaaaaaaaaaah';
}
?>
However, if I do the following:
<?php
for( $i = 0; $i < 10000000; $i++ )
{
ob_start();
echo 'blaaaaaaaaaaaaaaaaaaaaaaaaaah';
$foo .= ob_get_contents();
ob_end_clean();
}
?>
The run-time is approximately 3 times slower... not exactly expensive
considering it incorporates the concatenation as well as the output
buffering.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php