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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
1 + 32 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 09:01:28 2024 UTC