array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.stream-isatty.php', 1 => 'stream_isatty', ), 'up' => array ( 0 => 'ref.stream.php', 1 => 'ストリーム 関数', ), 'prev' => array ( 0 => 'function.stream-is-local.php', 1 => 'stream_is_local', ), 'next' => array ( 0 => 'function.stream-notification-callback.php', 1 => 'stream_notification_callback', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/stream/functions/stream-isatty.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7 >= 7.2.0, PHP 8)
stream_isatty — ストリームがターミナル型のデバイスかを調べる
stream
が、有効なターミナル型のデバイスを参照しているかを調べます。
この関数は、posix_isatty() よりも移植性に優れたバージョンです。
なぜなら、この関数は Windows でも動作するからです。
stream
例1 stream_isatty() の例
このコマンドは、標準出力 / 標準エラー出力 がファイルにリダイレクトされているかどうかを調べるのに使えます。
php -r "var_export(stream_isatty(STDERR));"
上の例の出力は、 たとえば以下のようになります。
php -r "var_export(stream_isatty(STDERR));" 2>output.txt
上の例の出力は、 たとえば以下のようになります。