Re: [PHP] ob_start changed from php4 to php5?

2005-08-19 Thread Marten Lehmann

Hello!


I'm also guessing that it's the LAST line of the file with the
"encodeDomain" function in it that you "include" in your test.php

I'm also guessing that there's a NEWLINE character after the final ?>
in that file on your 5.0.4 box, but that NEWLINE character is *NOT*
there on your 4.0 box.


No, there are no newlines at the end of any files. The problem was a new 
behavior of system() in PHP5:


"The system() call also tries to automatically flush the web server's 
output buffer after each line of output if PHP is running as a server 
module."


Obviously system() in PHP5 tries to flush, but because it's wrapped in 
ob_start() end ob_end_clean(), it's doesn't actually do. Unfortunately 
an interal flag in PHP is set to "output has been sent" anyway (bug?). I 
first changed it to passthru() instead of system(), but maybe I should 
use shell_exec() in the future.


Regards
Marten

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start changed from php4 to php5?

2005-08-18 Thread Jasper Bryant-Greene

Richard Lynch wrote:

Warning: Cannot modify header information - headers already sent in
test.php on line 4



I'm guessing that the error message has MORE information than that --
like the line number of the file in which the output occurred.

I'm also guessing that it's the LAST line of the file with the
"encodeDomain" function in it that you "include" in your test.php

I'm also guessing that there's a NEWLINE character after the final ?>
in that file on your 5.0.4 box, but that NEWLINE character is *NOT*
there on your 4.0 box.


It'd have to be two NEWLINE characters... PHP eats (does not output) any 
NEWLINE character immediately following a ?> closing PHP tag.


Jasper

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start changed from php4 to php5?

2005-08-17 Thread Richard Lynch
On Wed, August 17, 2005 10:12 am, Marten Lehmann wrote:
> I have a function catching the output of a script:
>
> function encodeDomain ($domain) {
>  ob_start();
>  system("echo '$domain'");
>  $output = ob_get_contents();
>  ob_end_clean();
> }
>
> And I have a php-script using this function:
>
> 
> encodeDomain($domain);
> header("Location: http://www.php.net";);
>
> ?>
>
> While this worked fine in PHP4, with PHP5.0.4 I always get the
> following
> error:
>
> Warning: Cannot modify header information - headers already sent in
> test.php on line 4

I'm guessing that the error message has MORE information than that --
like the line number of the file in which the output occurred.

I'm also guessing that it's the LAST line of the file with the
"encodeDomain" function in it that you "include" in your test.php

I'm also guessing that there's a NEWLINE character after the final ?>
in that file on your 5.0.4 box, but that NEWLINE character is *NOT*
there on your 4.0 box.

> The redirect works if I don't use the encodeDomain() function. Does
> the
> system-output affect the php-outout status in any way? I checked the
> raw
> http-output and I can see nothing of the output from the
> system()-call.
> Does maybe PHP simply say "output has been send" although it hasn't
> been
> send actually?

Sort of.

Apache may be buffering output, or you may even have output_buffering
set to "on" in php.ini or gzip may be involved and buffering or...

But as far as PHP is concerned, the headers went "out" even if
somebody else somewhere is buffering them and you don't see any
output.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ob_start changed from php4 to php5?

2005-08-17 Thread Rory Browne
This doesn't help with your ob problem, but if you simply want to
capture the output of the system cmd, then you can use $output =
shell_exec($command) instead of system() IIRC.

On 8/17/05, Marten Lehmann <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I have a function catching the output of a script:
> 
> function encodeDomain ($domain) {
> ob_start();
> system("echo '$domain'");
> $output = ob_get_contents();
> ob_end_clean();
> }
> 
> And I have a php-script using this function:
> 
>  
> encodeDomain($domain);
> header("Location: http://www.php.net";);
> 
> ?>
> 
> While this worked fine in PHP4, with PHP5.0.4 I always get the following
> error:
> 
> Warning: Cannot modify header information - headers already sent in
> test.php on line 4
> 
> The redirect works if I don't use the encodeDomain() function. Does the
> system-output affect the php-outout status in any way? I checked the raw
> http-output and I can see nothing of the output from the system()-call.
> Does maybe PHP simply say "output has been send" although it hasn't been
> send actually?
> 
> Regards
> Marten
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ob_start changed from php4 to php5?

2005-08-17 Thread Marten Lehmann

Hello,

I have a function catching the output of a script:

function encodeDomain ($domain) {
ob_start();
system("echo '$domain'");
$output = ob_get_contents();
ob_end_clean();
}

And I have a php-script using this function:

http://www.php.net";);

?>

While this worked fine in PHP4, with PHP5.0.4 I always get the following 
error:


Warning: Cannot modify header information - headers already sent in 
test.php on line 4


The redirect works if I don't use the encodeDomain() function. Does the 
system-output affect the php-outout status in any way? I checked the raw 
http-output and I can see nothing of the output from the system()-call. 
Does maybe PHP simply say "output has been send" although it hasn't been 
send actually?


Regards
Marten

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php