php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14003 fgetc from php://stdin doesn't return after one byte typed
Submitted: 2001-11-09 20:09 UTC Modified: 2002-07-24 16:57 UTC
Votes:27
Avg. Score:4.5 ± 1.0
Reproduced:21 of 23 (91.3%)
Same Version:5 (23.8%)
Same OS:4 (19.0%)
From: llam at alumni dot uwaterloo dot ca Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.0.6 OS: Linux 2.4.17
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: llam at alumni dot uwaterloo dot ca
New email:
PHP Version: OS:

 

 [2001-11-09 20:09 UTC] llam at alumni dot uwaterloo dot ca
<?

$rtdin = fopen("php://stdin", "r");

for(;;){
        $c = fgetc($rtdin);
        fflush($rtdin);
        if ($c == 'q') break;
        else echo "you pressed:" . $c . "\n";
}

?>

=========
This script doesn't work as expected: fgetc doesn't return until "\n" is read from stdin.

How can I catch single key-presses from the keyboard?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-24 16:57 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is a normal behavour, if you try simular code in C you will get the same results.
Consider using ncurses.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jun 15 11:01:24 2021 UTC