|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-08-13 21:40 UTC] tomsommer@php.net
[2004-08-13 22:42 UTC] tomsommer@php.net
[2005-02-12 04:04 UTC] cellog@php.net
[2005-02-12 09:54 UTC] wez@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 22:00:01 2025 UTC |
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) ""