Page 1 of 1

Cannot output before input

Posted: Sun Aug 17, 2003 11:24 pm
by chrislee
Hi All,

I rrun the following program at Windows command prompt

c:\php\cli\php.exe input.php

<?php
print "Input:";
flush();
$fp = fopen("php://stdin", "r");
$input = fgets($fp);
fclose($fp);
echo $input;
?>

The program did not show out "Input:" and waiting for input after run!
Any hint to flush the output first?

I am using PHP 4.3.2 (cli) (built: May 28 2003 15:10:38)

Posted: Mon Aug 18, 2003 1:26 am
by derek
I've checked your program and for your convenience I execute the program on windows platform. It's working fine. You check it again and let me know.

Posted: Mon Aug 18, 2003 1:59 am
by chrislee
derek,

I tried again, same result.
I am using Windows 2000 and PHP 4.3.2 (cli).
Which OS are you testing?

Posted: Mon Aug 18, 2003 10:09 pm
by chrislee
I found the solution, use ob_flush() instead.