register_shutdown_function and output buffering

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yawnmoth

    register_shutdown_function and output buffering

    Say I have the following PHP script:

    <?
    register_shutdo wn_function('te st');
    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_shutdo wn_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;
    }
    ?>

  • Jerry Stuckle

    #2
    Re: register_shutdo wn_function and output buffering

    yawnmoth wrote:[color=blue]
    > Say I have the following PHP script:
    >
    > <?
    > register_shutdo wn_function('te st');
    > 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_shutdo wn_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;
    > }
    > ?>
    >[/color]

    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.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    Working...