By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,409 Members | 1,524 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,409 IT Pros & Developers. It's quick & easy.

register_shutdown_function and output buffering

P: n/a
Say I have the following PHP script:

<?
register_shutdown_function('test');
ob_start();
echo "part2";

function test()
{
$output = ob_get_contents();
ob_end_clean();
echo "part1<br />".$output;
}
?>

The output of this is part2part1<br />. Why isn't it part1<br />part2?
register_shutdown_function should make the test function be the last
thing that's called, just as it is in the following, shouldn't it?:

<?
ob_start();
echo "part2";
test();

function test()
{
$output = ob_get_contents();
ob_end_clean();
echo "part1<br />".$output;
}
?>

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
yawnmoth wrote:
Say I have the following PHP script:

<?
register_shutdown_function('test');
ob_start();
echo "part2";

function test()
{
$output = ob_get_contents();
ob_end_clean();
echo "part1<br />".$output;
}
?>

The output of this is part2part1<br />. Why isn't it part1<br />part2?
register_shutdown_function should make the test function be the last
thing that's called, just as it is in the following, shouldn't it?:

<?
ob_start();
echo "part2";
test();

function test()
{
$output = ob_get_contents();
ob_end_clean();
echo "part1<br />".$output;
}
?>


Maybe because test() is called when the rest of the code is complete
(shutdown)?

Looks like the correct output to me.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.