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 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 52-- testing '1' -- 53 54Warning: readfile(1): failed to open stream: %s in %s on line %d 55-- testing '' -- 56 57Warning: readfile(): Filename cannot be empty in %s on line %d 58-- testing '' -- 59 60Warning: readfile(): Filename cannot be empty in %s on line %d 61-- testing '' -- 62 63Warning: readfile(): Filename cannot be empty in %s on line %d 64-- testing ' ' -- 65 66Warning: readfile( ): failed to open stream: %s in %s on line %d 67-- testing '' -- 68 69Warning: readfile() expects parameter 1 to be a valid path, string given in %s on line %d 70 71Notice: Array to string conversion in %s line %d 72-- testing 'Array' -- 73 74Warning: readfile() expects parameter 1 to be a valid path, array given in %s on line %d 75-- testing '%sdir' -- 76 77Warning: readfile(%sdir): failed to open stream: %s in %s on line %d 78-- testing '%sphp' -- 79 80Warning: readfile(%sphp): failed to open stream: %s in %s on line %d 81 82*** Done *** 83