Function name: stream_isatty()
Applicable version: PHP 5 >= 5.2.4, PHP 7
Function Description: Check whether the given file pointer is associated with a terminal device (i.e. whether it is an interactive terminal).
Usage: bool stream_isatty ( resource $stream )
parameter:
Return value: Return true if the given file pointer is associated with a terminal device, otherwise false.
Example: <?php $file = fopen('php://stdin', 'r'); if (stream_isatty($file)) { echo "文件指针关联到一个终端设备\n"; } else { echo "文件指针不关联到一个终端设备\n"; } fclose($file); ?-->
In the above example, we use the fopen() function to open a file pointer to a standard input stream and use the stream_isatty() function to check whether the file pointer is associated with a terminal device. According to the return value, we output the corresponding result.