1--TEST-- 2Test readfile() function : variation - various invalid paths 3--CREDITS-- 4Dave Kelsey <d_kelsey@uk.ibm.com> 5--SKIPIF-- 6<?php 7if(substr(PHP_OS, 0, 3) == "WIN") 8 die("skip Not for Windows"); 9?> 10--FILE-- 11<?php 12/* Prototype : int readfile(string filename [, bool use_include_path[, resource context]]) 13 * Description: Output a file or a URL 14 * Source code: ext/standard/file.c 15 * Alias to functions: 16 */ 17 18echo "*** Testing readfile() : variation ***\n"; 19 20 21/* An array of files */ 22$names_arr = array( 23 /* Invalid args */ 24 -1, 25 TRUE, 26 FALSE, 27 NULL, 28 "", 29 " ", 30 "\0", 31 array(), 32 33 /* prefix with path separator of a non existing directory*/ 34 "/no/such/file/dir", 35 "php/php" 36 37); 38 39for( $i=0; $i<count($names_arr); $i++ ) { 40 $name = $names_arr[$i]; 41 echo "-- testing '$name' --\n"; 42 var_dump(readfile($name)); 43} 44 45echo "\n*** Done ***\n"; 46?> 47--EXPECTF-- 48*** Testing readfile() : variation *** 49-- testing '-1' -- 50 51Warning: readfile(-1): failed to open stream: %s in %s on line %d 52bool(false) 53-- testing '1' -- 54 55Warning: readfile(1): failed to open stream: %s in %s on line %d 56bool(false) 57-- testing '' -- 58 59Warning: readfile(): Filename cannot be empty in %s on line %d 60bool(false) 61-- testing '' -- 62 63Warning: readfile(): Filename cannot be empty in %s on line %d 64bool(false) 65-- testing '' -- 66 67Warning: readfile(): Filename cannot be empty in %s on line %d 68bool(false) 69-- testing ' ' -- 70 71Warning: readfile( ): failed to open stream: %s in %s on line %d 72bool(false) 73-- testing '' -- 74bool(false) 75-- testing 'Array' -- 76 77Warning: readfile() expects parameter 1 to be string, array given in %s on line %d 78bool(false) 79-- testing '%sdir' -- 80 81Warning: readfile(%sdir): failed to open stream: %s in %s on line %d 82bool(false) 83-- testing '%sphp' -- 84 85Warning: readfile(%sphp): failed to open stream: %s in %s on line %d 86bool(false) 87 88*** Done *** 89