xref: /PHP-8.2/tests/output/stream_isatty.inc (revision 852485d8)
1<?php
2
3function testToStdOut()
4{
5    $sampleStreams = array(
6        'STDIN (constant)'              => STDIN,
7        'STDIN (fopen)'                 => fopen('php://stdin', 'rb'),
8        'STDIN (php://fd/0)'            => fopen('php://fd/0', 'rb'),
9        'STDOUT (constant)'             => STDOUT,
10        'STDOUT (fopen)'                => fopen('php://stdout', 'wb'),
11        'STDOUT (php://fd/1)'           => fopen('php://fd/1', 'wb'),
12        'STDERR (constant)'             => STDERR,
13        'STDERR (fopen)'                => fopen('php://stderr', 'wb'),
14        'STDERR (php://fd/2)'           => fopen('php://fd/2', 'wb'),
15        'Invalid stream (php://temp)'   => fopen('php://temp', 'wb'),
16        'Invalid stream (php://input)'  => fopen('php://input', 'wb'),
17        'Invalid stream (php://memory)' => fopen('php://memory', 'wb'),
18        'File stream'                   => $closeMe = fopen(__FILE__, 'rb'),
19    );
20
21    foreach ($sampleStreams as $name => $stream) {
22        echo "$name: "; var_dump(stream_isatty($stream));
23    }
24
25    fclose($closeMe);
26}
27
28function testToStdErr()
29{
30    ob_start();
31    testToStdOut();
32    $result = ob_get_contents();
33    ob_end_clean();
34    fwrite(STDERR, $result);
35}
36