1--TEST-- 2Test popen() and pclose function: error conditions 3--SKIPIF-- 4<?php 5if( substr(PHP_OS, 0, 3) != 'Sun') 6 die("skip Only valid for Sun Solaris"); 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 ***\n"; 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) ); 25fclose($file_handle); 26var_dump( pclose(1) ); 27echo "\n--- 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: Wrong parameter count for popen() in %s on line %d 38NULL 39 40Warning: Wrong parameter count for popen() in %s on line %d 41NULL 42sh: abc.txt: not found 43resource(%d) of type (stream) 44 45Warning: Wrong parameter count for pclose() in %s on line %d 46NULL 47 48Warning: Wrong parameter count for pclose() in %s on line %d 49NULL 50 51Warning: pclose(): supplied argument is not a valid stream resource in %s on line %d 52bool(false) 53 54--- Done --- 55