|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-11-30 15:14 UTC] tony2001@php.net
[2006-11-30 15:33 UTC] guessousmehdi at hotmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 19:00:01 2025 UTC |
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.