From:             [EMAIL PROTECTED]
Operating system: Win32 & Linux
PHP version:      5.0.1
PHP Bug Type:     CGI related
Bug description:  php://stdin does not wait for input after first run

Description:
------------
The code below works in PHP4, but not in PHP 5.0.1

After first being prompted for stdin input and clicking enter the rest of
the loop finishes without waiting for user interaction

Run the code below in CLI.
Enter "foo"[ENTER]

Reproduced in both Win32 and Linux

Reproduce code:
---------------
<?php
    for($i = 0; $i <= 10; $i++ ) {
        echo 'Please enter a number: ';
        $fp = fopen('php://stdin', 'r');
        $answr = trim(fgets($fp, 1024));
        var_dump($answr);
        fclose($fp);
    }
?>

Expected result:
----------------
Please enter something: foo
string(3) "foo"
Please enter something: 

Actual result:
--------------
Please enter something: foo
string(3) "foo"
Please enter something: string(0) ""
Please enter something: string(0) ""
Please enter something: string(0) ""
Please enter something: string(0) ""
Please enter something: string(0) ""
Please enter something: string(0) ""
Please enter something: string(0) ""
Please enter something: string(0) ""
Please enter something: string(0) ""
Please enter something: string(0) ""

-- 
Edit bug report at http://bugs.php.net/?id=29663&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29663&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29663&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29663&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29663&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29663&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29663&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29663&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29663&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29663&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29663&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29663&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29663&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29663&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29663&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29663&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29663&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29663&r=float

Reply via email to