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