1--TEST-- 2Test popen() and pclose function: error conditions 3 4--SKIPIF-- 5<?php 6if(substr(PHP_OS, 0, 3) != 'WIN' && PHP_DEBUG) die("skip Valid only on Windows"); 7if(!PHP_DEBUG) die("skip Not Valid for release builds"); 8 9ob_start();phpinfo(INFO_GENERAL);$inf=ob_get_contents(); ob_end_clean(); 10if (!(strpos($inf, 'MSVC9') || strpos($inf, 'MSVC8'))) die("skip Not Valid for build done with VC < 8"); 11?> 12 13--FILE-- 14<?php 15/* 16 * Prototype: resource popen ( string command, string mode ) 17 * Description: Opens process file pointer. 18 19 * Prototype: int pclose ( resource handle ); 20 * Description: Closes process file pointer. 21 */ 22$file_path = dirname(__FILE__); 23echo "*** Testing for error conditions ***\n"; 24var_dump( popen() ); // Zero Arguments 25var_dump( popen("abc.txt") ); // Single Argument 26var_dump( popen("abc.txt", "rw") ); // Invalid mode Argument 27var_dump( pclose() ); 28$file_handle = fopen($file_path."/popen.tmp", "w"); 29var_dump( pclose($file_handle, $file_handle) ); 30pclose($file_handle); 31var_dump( pclose(1) ); 32echo "\n--- Done ---"; 33?> 34--CLEAN-- 35<?php 36$file_path = dirname(__FILE__); 37unlink($file_path."/popen.tmp"); 38?> 39--EXPECTF-- 40*** Testing for error conditions *** 41 42Warning: popen() expects exactly 2 parameters, 0 given in %s on line %d 43NULL 44 45Warning: popen() expects exactly 2 parameters, 1 given in %s on line %d 46NULL 47 48Warning: Invalid parameter detected in CRT function '_fdopen' (%s:%d) in %s on line %d 49 50Warning: popen(abc.txt,rw): Invalid argument in %s on line %d 51bool(false) 52 53Warning: pclose() expects exactly 1 parameter, 0 given in %s on line %d 54bool(false) 55 56Warning: pclose() expects exactly 1 parameter, 2 given in %s on line %d 57bool(false) 58 59Warning: pclose() expects parameter 1 to be resource, integer given in %s on line %d 60bool(false) 61 62--- Done ---'abc.txt' is not recognized as an internal or external command, 63operable program or batch file. 64