note 125664 added to function.posix-isatty

From: Date: Fri, 08 Jan 2021 10:34:46 +0000
Subject: note 125664 added to function.posix-isatty
Groups: php.notes 
Request: Send a blank email to php-notes+get-216073@lists.php.net to get a copy of this message
It's quite complicated to understand its movements. But it determines if the file_descriptor is open AND connected to a terminal. Thus, while receiving data from the STDIN, for example, it will return false. This move is useful to optionally pipe STDIN to a PHP script, to avoid hanging when nothing is from STDIN. <?php // Simply echoes the contents from STDIN if any // and "no stdin" if not. echo (posix_isatty(STDIN)) ? 'no stdin' . PHP_EOL : file_get_contents('php://stdin'); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.159.165 (proxied: 122.219.245.20) ---- Manual Page -- http://php.net/manual/en/function.posix-isatty.php Edit -- https://master.php.net/note/edit/125664 Del: integrated -- https://master.php.net/note/delete/125664/integrated Del: useless -- https://master.php.net/note/delete/125664/useless Del: bad code -- https://master.php.net/note/delete/125664/bad+code Del: spam -- https://master.php.net/note/delete/125664/spam Del: non-english -- https://master.php.net/note/delete/125664/non-english Del: in docs -- https://master.php.net/note/delete/125664/in+docs Del: other reasons-- https://master.php.net/note/delete/125664 Reject -- https://master.php.net/note/reject/125664 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#216073) next »