Are there best practices for handling user input in PHP CLI scripts to prevent the script from pausing for input?

When writing PHP CLI scripts, it's important to handle user input in a way that prevents the script from pausing for input. One way to achieve this is by using the `fgets(STDIN)` function to read input from the command line without pausing. By checking if input is available before reading, you can ensure that the script continues to execute without interruption.

$input = '';
if (false === ftell(STDIN)) {
    stream_set_blocking(STDIN, false);
}
if (false !== ($char = fgetc(STDIN))) {
    $input .= $char;
}