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? 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 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!"); ?> Link to comment https://forums.phpfreaks.com/topic/55535-php-user-input/#findComment-274425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.