CakeFest 2024: The Official CakePHP Conference

posix_ctermid

(PHP 4, PHP 5, PHP 7, PHP 8)

posix_ctermid制御する端末のパス名を得る

説明

posix_ctermid(): string|false

そのプロセスで現在制御している端末のパス名を表す文字列を作成します。 エラーが発生した場合は errno を設定します。この値を調べるには posix_get_last_error() を使用します。

パラメータ

この関数にはパラメータはありません。

戻り値

処理に成功した場合は、現在制御している端末のパス名を表す文字列を返します。 それ以外の場合は false を返し、errno を設定します。 この値を調べるには posix_get_last_error() を使用します。

例1 posix_ctermid() の例

この例は、現在の TTY へのパスを表示します。

<?php
echo "I am running from ".posix_ctermid();
?>

参考

add a note

User Contributed Notes 1 note

up
0
phpmanual at remove dot mark dot griffin dot email
7 years ago
You can write directly to the tty (screen) even when the shell has redirected output, with:

<?php
$h
= fopen(posix_ctermid(), "rb+");
fwrite($h, "Testing direct output\n");
fclose($h);
?>
To Top