Re: Can PHP determine if the STDOUT to a CLI script is being redirected?
| From: | Per Jessen | Date: | Wed, 22 Apr 2009 10:10:18 +0000 |
| Subject: | Re: Can PHP determine if the STDOUT to a CLI script is being redirected? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-291805@lists.php.net to get a copy of this message | ||
Richard Quadling wrote:
> 2009/4/22 Per Jessen <per@computer.org>:
>> Richard Quadling wrote:
>>
>>> Hi.
>>>
>>> Is there a simple way for a CLI based PHP script to determine if its
>>> output is being redirected to a file or piped through a filter
>>> (find, sort, etc.)
>>>
>>> I'm using ANSI escape sequences to colour the output (all working
>>> very nicely), but I want to suppress the codes if the output is
>>> being filtered or redirected to a file.
>>
>> Check out posix_isatty()
>>
>> /Per
>>
>
> For windows?
Sorry, I have no idea.
/Per
--
Per Jessen, Zürich (16.1°C)