The Little Guy Posted June 14, 2007 Share Posted June 14, 2007 When running PHP as a binary, is there a way to ask for user input? Quote Link to comment https://forums.phpfreaks.com/topic/55535-php-user-input/ Share on other sites More sharing options...
btherl Posted June 14, 2007 Share Posted June 14, 2007 Here's the very basic form: <? while (!feof(STDIN)) { $buf = fgets(STDIN); print $buf; } ?> Don't ask me about character at a time input.. I'm sure it's possible, but I don't know how to enable it Quote Link to comment https://forums.phpfreaks.com/topic/55535-php-user-input/#findComment-274420 Share on other sites More sharing options...
The Little Guy Posted June 14, 2007 Author Share Posted June 14, 2007 Here we go: <?php $name = fwrite(STDOUT, "Enter your name: "); $name = trim(fgets(STDIN)); // write input back fwrite(STDOUT, "Hello, $name!"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/55535-php-user-input/#findComment-274425 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.