« stream_is_local
stream_notification_callback »

stream_isatty

(PHP 7 >= 7.2.0, PHP 8)

stream_isatty — ストリームがターミナル型のデバイスかを調べる

説明

function stream_isatty(resource $stream): bool

stream が、有効なターミナル型のデバイスを参照しているかを調べます。 この関数は、posix_isatty() よりも移植性に優れたバージョンです。 なぜなら、この関数は Windows でも動作するからです。

パラメータ

stream

戻り値

成功した場合に true を、失敗した場合に false を返します。

例

例1 stream_isatty() の例

このコマンドは、標準出力 / 標準エラー出力 がファイルにリダイレクトされているかどうかを調べるのに使えます。

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

上の例の出力は、 たとえば以下のようになります。


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

上の例の出力は、 たとえば以下のようになります。


false

関連キーワード:
stream   isatty   ストリーム   ターミナル   デバイス   export   local   notification   callback   resource   移植性   Windows   成功   リダイレクト   output
関連する関数・ページ:
function.stream-is-local   function.posix-isatty   function.stream-get-contents   function.stream-set-read-buffer   function.stream-supports-lock   function.stream-context-get-options