Cannot output before input

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chrislee
Forum Newbie
Posts: 6
Joined: Fri Jul 25, 2003 8:21 pm

Cannot output before input

Post 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)
derek
Forum Newbie
Posts: 17
Joined: Sat Aug 16, 2003 11:31 am

Post 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.
chrislee
Forum Newbie
Posts: 6
Joined: Fri Jul 25, 2003 8:21 pm

Post by chrislee »

derek,

I tried again, same result.
I am using Windows 2000 and PHP 4.3.2 (cli).
Which OS are you testing?
chrislee
Forum Newbie
Posts: 6
Joined: Fri Jul 25, 2003 8:21 pm

Post by chrislee »

I found the solution, use ob_flush() instead.
Post Reply