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