note 90815 added to function.fgetc
| From: | alex at alexdemers dot me | Date: | Mon, 11 May 2009 17:30:50 +0000 |
| Subject: | note 90815 added to function.fgetc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-154455@lists.php.net to get a copy of this message | ||
The best and simplest way to get input from a user in the CLI with only PHP is to use fgetc()
function with the STDIN constant:
<?php
echo 'Are you sure you want to quit? (y/n) ';
$input = fgetc(STDIN);
if ($input == 'y')
{
exit(0);
}
?>
----
Server IP: 72.55.140.6
Probable Submitter: 208.124.129.220
----
Manual Page -- http://www.php.net/manual/en/function.fgetc.php
Edit -- https://master.php.net/note/edit/90815
Del: integrated -- https://master.php.net/note/delete/90815/integrated
Del: useless -- https://master.php.net/note/delete/90815/useless
Del: bad code -- https://master.php.net/note/delete/90815/bad+code
Del: spam -- https://master.php.net/note/delete/90815/spam
Del: non-english -- https://master.php.net/note/delete/90815/non-english
Del: in docs -- https://master.php.net/note/delete/90815/in+docs
Del: other reasons-- https://master.php.net/note/delete/90815
Reject -- https://master.php.net/note/reject/90815
Search -- https://master.php.net/manage/user-notes.php