note 103045 added to function.fgetc

From: Date: Tue, 22 Mar 2011 14:33:12 +0000
Subject: note 103045 added to function.fgetc
Groups: php.notes 
Request: Send a blank email to php-notes+get-178095@lists.php.net to get a copy of this message
To read a single key-press in CLI mode, you can either use ncurses (which will probably require additional modules for PHP) or get nasty with the *nix "/bin/stty" command) <?php function stty($options) { exec($cmd = "/bin/stty $options", $output, $el); $el AND die("exec($cmd) failed"); return implode(" ", $output); } function getchar($echo = false) { $echo = $echo ? "" : "-echo"; # Get original settings $stty_settings = preg_replace("#.*; ?#s", "", stty("--all")); # Set new ones stty("cbreak $echo"); # Get characters until a PERIOD is typed, # showing their hexidecimal ordinal values. printf("> "); do { printf("%02x ", ord($c = fgetc(STDIN))); } while ($c != '.'); # Return settings stty($stty_settings); } getchar(); ?> ---- Server IP: 192.41.42.26 Probable Submitter: 124.190.251.137 ---- Manual Page -- http://www.php.net/manual/en/function.fgetc.php Edit -- https://master.php.net/note/edit/103045 Del: integrated -- https://master.php.net/note/delete/103045/integrated Del: useless -- https://master.php.net/note/delete/103045/useless Del: bad code -- https://master.php.net/note/delete/103045/bad+code Del: spam -- https://master.php.net/note/delete/103045/spam Del: non-english -- https://master.php.net/note/delete/103045/non-english Del: in docs -- https://master.php.net/note/delete/103045/in+docs Del: other reasons-- https://master.php.net/note/delete/103045 Reject -- https://master.php.net/note/reject/103045 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178095) next »