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