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 run only on Windows"); 9?> 10--CONFLICTS-- 11obscure_filename 12--FILE-- 13<?php 14/* Prototype : int readfile(string filename [, bool use_include_path[, resource context]]) 15 * Description: Output a file or a URL 16 * Source code: ext/standard/file.c 17 * Alias to functions: 18 */ 19 20echo "*** Testing readfile() : variation ***\n"; 21 22/* An array of files */ 23$names_arr = array( 24 /* Invalid args */ 25 "-1" => -1, 26 "TRUE" => TRUE, 27 "FALSE" => FALSE, 28 "NULL" => NULL, 29 "\"\"" => "", 30 "\" \"" => " ", 31 "\\0" => "\0", 32 "array()" => array(), 33 34 /* prefix with path separator of a non existing directory*/ 35 "/no/such/file/dir" => "/no/such/file/dir", 36 "php/php"=> "php/php" 37 38); 39 40foreach($names_arr as $key => $value) { 41 echo "\n-- Filename: $key --\n"; 42 readfile($value); 43}; 44 45?> 46--EXPECTF-- 47*** Testing readfile() : variation *** 48 49-- Filename: -1 -- 50 51Warning: readfile(-1): failed to open stream: No such file or directory in %s on line %d 52 53-- Filename: TRUE -- 54 55Warning: readfile(1): failed to open stream: No such file or directory in %s on line %d 56 57-- Filename: FALSE -- 58 59Warning: readfile(): Filename cannot be empty in %s on line %d 60 61-- Filename: NULL -- 62 63Warning: readfile(): Filename cannot be empty in %s on line %d 64 65-- Filename: "" -- 66 67Warning: readfile(): Filename cannot be empty in %s on line %d 68 69-- Filename: " " -- 70 71Warning: readfile( ): failed to open stream: Permission denied in %s on line %d 72 73-- Filename: \0 -- 74 75Warning: readfile() expects parameter 1 to be a valid path, string given in %s on line %d 76 77-- Filename: array() -- 78 79Warning: readfile() expects parameter 1 to be a valid path, array given in %s on line %d 80 81-- Filename: /no/such/file/dir -- 82 83Warning: readfile(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d 84 85-- Filename: php/php -- 86 87Warning: readfile(php/php): failed to open stream: No such file or directory in %s on line %d 88