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} 11if (PHP_DEBUG) { 12 die("skip std streams are not closeable in debug builds"); 13} 14if (getenv('SKIP_REPEAT')) { 15 die("skip cannot be repeated"); 16} 17?> 18--FILE-- 19<?php 20 21$stdin = fopen('php://stdin', 'r'); 22$stdout = fopen('php://stdout', 'r'); 23$stderr = fopen('php://stderr', 'r'); 24 25ob_start(function ($buffer) use ($stdout) { 26 fwrite($stdout, $buffer); 27}, 1); 28 29print "STDIN:\n"; 30fclose(STDIN); 31var_dump(@fopen('php://stdin', 'r')); 32 33print "STDERR:\n"; 34fclose(STDERR); 35var_dump(@fopen('php://stderr', 'a')); 36 37print "STDOUT:\n"; 38fclose(STDOUT); 39var_dump(@fopen('php://stdout', 'a')); 40?> 41--EXPECT-- 42STDIN: 43bool(false) 44STDERR: 45bool(false) 46STDOUT: 47bool(false) 48