Re: Re: output buffering callback limitation
| From: | Andre Cerqueira | Date: | Mon, 14 Jun 2004 18:26:49 +0000 |
| Subject: | Re: Re: output buffering callback limitation | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-10452@lists.php.net to get a copy of this message | ||
I think an ob_handler should be designed to handle output.
Not create (output), nor send emails.
I think the workaround is the other way around hehe
It's the way you want it to work that is a workaround, since there is probably a better way to do it.
-I agree, print_r($var, true) should work but doesn't.
You could print_r() before or after ob_handler being called (upon script end or ob_end_flush, or something like that)
-I think you could still send the email from the ob_handler (though i think it's ugly) and keep the separation if you read the template file and handle it instead of including directly after a ob_start() (that's what you're doing, right?)
Or you could send the email out of the ob_handler
One would allow ob_start to be called inside an ob_handler, and the error message would be printed only if output buffering is always on at >the end of this ob_handler, it would be perfect !Not sure if i undertood you. Are you trying to emit errors during ob_handler execution and prevent them from being output using ob_start()? You could use error_reporting()+error_log()[+trigger_error()] or something? Okin okin wrote:
One last note on this : the limitation I'm talking about is annoying in two cases for me : - I can't use "print_r($var, true)" inside an ob_handler, because print_r uses ob_start internally. And I need this to append some debug info to my buffer. The workaround for this is to make my own print_r... - In some cases, I would like to send an email from an ob_handler. But I make my emails with some logic/presentation separation. And most if not all template systems use ob_start to fetch their output into a $variable. The workaround here is to register_shutdown_function the mail-sending function inside the ob_handler. As you can see, I've two real problems, and a real solution (by PHP source mods) could be far better than two workarounds isn't it ? One would allow ob_start to be called inside an ob_handler, and the error message would be printed only if output buffering is always on at the end of this ob_handler, it would be perfect ! Please consider this idea, and thank you for your patience. Nikos Taco van den Broek <taco@procurios.nl> wrote: Okin okin wrote:I'm having trouble with output buffering limitation and the output_callback function of ob_start. look at this script : function ob_perso_handler($buffer) { ob_start(); echo 'foo'; $buffer .= ob_get_contents(); ob_end_clean(); return $buffer; } ob_start('ob_perso_handler'); echo 'Hello World !'; ?> it outputs : "Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers"I don't really understand your problem, it seams to me you want to add output to the buffer in the output handler!? Why not just: <?php function myObHandler($buffer) { $buffer .= 'foo'; return $buffer; } ob_start('myObHandler'); ?> --------------------------------- Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! Créez votre Yahoo! Mail Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc