PHP Function Reference

PHP stream_isatty() Function



The PHP stream_isatty() function is used to check whether the specified stream is connected or associated with a terminal type device or not.

Syntax

stream_isatty(stream)

Parameters

stream Required. Specify the stream resource to check.

Return Value

Returns true on success or false on failure.

Example: stream_isatty() example

The below command can be used to determine if a standard output / standard error stream is redirected to a file.

php -r "var_export(stream_isatty(STDERR));"

The output of the above command will be similar to:

true

php -r "var_export(stream_isatty(STDERR));" 2>output.txt

The output of the above command will be similar to:

false

❮ PHP Streams Reference