im trying to make a console script with commands in batch with php,
and i have found this script:
for(;;){
fwrite(STDOUT, "\n");
$name = fgets(STDIN);
fwrite(STDOUT, "Hello $name");
sleep(1);
}
but it stops on every loop ,
can i make a loop and use this function as well ?
thanks ..
You can use
stream_select()to wait for data to appear in the STDIN. The optional timeout value let you go do something else when there is no input. The following code will keep printing “Waiting…” every 200 ms until you enter something: