Newbie question about PHP CLI and STDIN
Posted: Thu Aug 03, 2006 5:08 pm
How can a ask the user to enter a bit of text in STDIN but present them with a default value (for example, the one they last used) which they can either edit, backspace out or just use?
Hopefully this example will get over what I mean:
I don't want to have to use readline or ncurses and I'm guessing it's not even needed.
Hopefully this example will get over what I mean:
Code: Select all
<?php
echo "Enter something: ";
fwrite(STDIN, 'Foo');
$line = fgets(STDIN); //User sees "Enter something: Foo -- but godammit they can't backspace the word Foo out again"
echo "\n\n$line";
?>