xref: /PHP-8.3/sapi/cli/tests/gh8827-002.phpt (revision 0a4a55fd)
1--TEST--
2std handles can be deliberately closed 002
3--SKIPIF--
4<?php
5if (php_sapi_name() != "cli") {
6	die("skip CLI only");
7}
8if (PHP_OS_FAMILY == 'Windows') {
9	die("skip not for Windows");
10}
11?>
12--FILE--
13<?php
14
15$stdin = fopen('php://stdin', 'r');
16$stdout = fopen('php://stdout', 'r');
17$stderr = fopen('php://stderr', 'r');
18
19ob_start(function ($buffer) use ($stdout) {
20    fwrite($stdout, $buffer);
21}, 1);
22
23print "STDIN:\n";
24fclose(STDIN);
25var_dump(@fopen('php://stdin', 'r'));
26
27print "STDERR:\n";
28fclose(STDERR);
29var_dump(@fopen('php://stderr', 'a'));
30
31print "STDOUT:\n";
32fclose(STDOUT);
33var_dump(@fopen('php://stdout', 'a'));
34?>
35--EXPECT--
36STDIN:
37bool(false)
38STDERR:
39bool(false)
40STDOUT:
41bool(false)
42