ID: 29663 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] 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] [EMAIL PROTECTED] Apparently this in intended behaviour for CLI scripts. ------------------------------------------------------------------------ [2004-08-13 21:40:44] [EMAIL PROTECTED] Using the STDIN constant works. Removing fclose() in the above example does not solve the problem. ------------------------------------------------------------------------ [2004-08-13 21:22:28] [EMAIL PROTECTED] 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