>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?

Nop, I'm considering this :

<?php
function ob_perso_handler($buffer) {
  ob_start();
  echo 'foo';
  return $buffer . ob_get_clean();
}

ob_start('ob_perso_handler');

echo 'Hello World !';
?>

this code produces "Fatal error: ob_start(): Cannot
use output [...]"

the idea is that the above code don't makes error
anymore, but this one yes

<?php
function ob_perso_handler($buffer) {
  ob_start();
  echo 'foo';
  return $buffer;
}

ob_start('ob_perso_handler');

echo 'Hello World !';
?>

with an error message like this one : 
"Fatal error: each output buffer started inside an
ob_handler must be destroyed before the end of this
ob_handler"


>Andre Cerqueira <[EMAIL PROTECTED]> wrote: 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.
> 
> 
> 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"



        

        
                
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! 
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! 
Messenger sur http://fr.messenger.yahoo.com

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to