开发者

Detect console end of the input in PHP-Cli

开发者 https://www.devze.com 2023-03-13 03:31 出处:网络
Is there any form to detect the end of a console input? Im using something like this: <?php while($consoleInput = fgets(S开发者_运维问答TDIN)) {

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

Im using something like this:

<?php
while($consoleInput = fgets(S开发者_运维问答TDIN)) {

 //do something

}
?>

Any sugestions?


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

while (!feof(STDIN)) {
  $consoleInput = fgets(STDIN);
}


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

精彩评论

暂无评论...
验证码 换一张
取 消