xref: /PHP-7.4/tests/output/stream_isatty.inc (revision 33301d5b)
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        'Not a stream'                  => 'foo',
16        'Invalid stream (php://temp)'   => fopen('php://temp', 'wb'),
17        'Invalid stream (php://input)'  => fopen('php://input', 'wb'),
18        'Invalid stream (php://memory)' => fopen('php://memory', 'wb'),
19        'File stream'                   => $closeMe = fopen(__FILE__, 'rb'),
20    );
21
22    foreach ($sampleStreams as $name => $stream) {
23        echo "$name: "; var_dump(stream_isatty($stream));
24    }
25
26    fclose($closeMe);
27}
28
29function testToStdErr()
30{
31    ob_start();
32    testToStdOut();
33    $result = ob_get_contents();
34    ob_end_clean();
35    fwrite(STDERR, $result);
36}
37