ID:               39693
 Updated by:       [EMAIL PROTECTED]
 Reported By:      guessousmehdi at hotmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Output Control
 Operating System: windows
 PHP Version:      5.2.0
 New Comment:

This is expected behaviour.
Object destructors are called before flushing the output buffers, so if
your object has refcount == 1 (which is the case with $t2=$t1 commented
out), $t1 is already destroyed when the callback is called.
You do not see the error message, because the error happens in the
function which flushes the buffer, so this is also expected.


Previous Comments:
------------------------------------------------------------------------

[2006-11-30 14:57:56] guessousmehdi at hotmail dot com

Description:
------------
When I  terminate a script by an exit,
before end  of execution, ob_start allows to 
to invoke a callback function.
>From this callback function, I cannot access to an 
object (in source example:$t1) previously initiated in the script. 
However, if I save a dummy copy of that object in a new variable (for
instance $t2), then it work as expected.
In the source example, just uncomment the line "$t2=$t1;"
to see what I mean.
I works normally in previous version of php (php 4 and first releases
of 5)
I cannot remplace the exit at the end by an ob_flush(), because I'm
including a big script in my real work, which is much more complex than
the example I provide.

Reproduce code:
---------------
<?php
class test{
        function nice_string(){
                 return "hello world, how are you ?";
        }       
}
$t1 =  new test();

// the following commented line makes a difference 
//$t2=$t1;

function callbackfunc($output){
         global $t1;                    
   $output ="chocolate<br>". $output . "<br>". $t1->nice_string();    

        return "$output";
}
ob_start('callbackfunc');
echo "what a nice day";
exit();  ?>

Expected result:
----------------
should output:
chocolate
what a nice day
hello world, how are you ?

Actual result:
--------------
output nothing,
blank page,
probably a fatal error without any indication about it.

Uncommenting line $t2=$t1 and it works fine again.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39693&edit=1

Reply via email to