0

Is there any form to detect the end of a console input?

Im using something like this:

<?php
while($consoleInput = fgets(STDIN)) {

 //do something

}
?>

Any sugestions?

1
  • Welcome to Stack Overflow! If you feel your question has been sufficiently answered, please click on the checkmark to accept it. Also vote up all answers you found useful in any way. Commented Jun 13, 2011 at 16:36

2 Answers 2

1

How about feof()? Untested, but I believe this will work.

while (!feof(STDIN)) {
  $consoleInput = fgets(STDIN);
}
Sign up to request clarification or add additional context in comments.

Comments

0
if (feof(STDIN)) {
   do_something()
};

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.