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

From: Date: Sat, 12 Feb 2005 03:04:42 +0000
Subject: #29663 [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-73928@lists.php.net to get a copy of this message
ID: 29663 Updated by: cellog@php.net Reported By: tomsommer@php.net Status: Bogus Bug Type: CGI related Operating System: Win32 & Linux PHP Version: 5.0.1 New Comment: This is a major BC break with PHP 4, and breaks the PEAR installer's PEAR_Frontend_CLI::userDialog() function. I strongly suggest reconsidering the "bogus" mark Previous Comments: ------------------------------------------------------------------------ [2004-08-13 22:42:54] tomsommer@php.net Apparently this in intended behaviour for CLI scripts. ------------------------------------------------------------------------ [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 (#73928) next »