#29663 [Opn->Bgs]: php://stdin does not wait for input after first run

From: Date: Fri, 13 Aug 2004 20:42:55 +0000
Subject: #29663 [Opn->Bgs]: php://stdin does not wait for input after first run
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-64579@lists.php.net to get a copy of this message
ID: 29663 Updated by: tomsommer@php.net Reported By: tomsommer@php.net -Status: Open +Status: Bogus Bug Type: CGI related Operating System: Win32 & Linux PHP Version: 5.0.1 New Comment: Apparently this in intended behaviour for CLI scripts. Previous Comments: ------------------------------------------------------------------------ [2004-08-13 21:40:44] tomsommer@php.net Using the STDIN constant works. Removing fclose() in the above example does not solve the problem. ------------------------------------------------------------------------ [2004-08-13 21:22:28] tomsommer@php.net 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 this bug report at http://bugs.php.net/?id=29663&edit=1

« previous php.bugs (#64579) next »