rosenrosen Posted September 19, 2008 Share Posted September 19, 2008 I'd like to read something from STDIN using something like: echo "Enter your name: \n"; $name = trim(fgets(STDIN)); First, how can I echo the characters to the screen at the same time so the person can see what they are typing? Second is there a way to get it to work without the "\n" in the echo statement? I'd like the text to appear on the same line as the prompt. Thanks. Link to comment https://forums.phpfreaks.com/topic/124994-solved-readin-from-stdin/ Share on other sites More sharing options...
ratcateme Posted September 19, 2008 Share Posted September 19, 2008 what about making a function that receives one char echos that out then receives another until it can find a \r\n and it returns the string without the \r\n and taking out the \n should be no problem Scott. Link to comment https://forums.phpfreaks.com/topic/124994-solved-readin-from-stdin/#findComment-645873 Share on other sites More sharing options...
rosenrosen Posted September 19, 2008 Author Share Posted September 19, 2008 Looks like putting flush(); below the echo statement has solved both problems! Link to comment https://forums.phpfreaks.com/topic/124994-solved-readin-from-stdin/#findComment-645935 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.