Hi, I am using PHP in CLI mode (command line interface)
I would like to receive the key that the user enters, and immediately send it to the program without having to press the return key (Enter Key) So, for example, I liked typing a letter that the user enters immediately. Therefore, if the user enters "a", he immediately displays "a" on the command line. How should I do it?
do {
$selection = fgetc(STDIN);
fwrite(STOUT, "$selection");
} while ( trim($selection) == '' );
source
share