note 89801 added to function.fgetc

From: Date: Tue, 24 Mar 2009 03:08:47 +0000
Subject: note 89801 added to function.fgetc
Groups: php.notes 
Request: Send a blank email to php-notes+get-152362@lists.php.net to get a copy of this message
I was using command-line PHP to create an interactive script and wanted the user to enter just one character of input - in response a Yes/No question. Had some trouble finding a way to do so using fgets(), fgetc(), various suggestions using readline(), popen(), etc. Came up with the following that works quite nicely: $ans = strtolower( trim( bash -c "read -n 1 -t 10 ANS ; echo \\\$ANS" ) ); ---- Server IP: 208.69.120.35 Probable Submitter: 96.48.169.203 ---- Manual Page -- http://www.php.net/manual/en/function.fgetc.php Edit -- https://master.php.net/note/edit/89801 Del: integrated -- https://master.php.net/note/delete/89801/integrated Del: useless -- https://master.php.net/note/delete/89801/useless Del: bad code -- https://master.php.net/note/delete/89801/bad+code Del: spam -- https://master.php.net/note/delete/89801/spam Del: non-english -- https://master.php.net/note/delete/89801/non-english Del: in docs -- https://master.php.net/note/delete/89801/in+docs Del: other reasons-- https://master.php.net/note/delete/89801 Reject -- https://master.php.net/note/reject/89801 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152362) next »