1--TEST-- 2Test is_readable() function: usage variations - diff. file notations 3--SKIPIF-- 4<?php 5require __DIR__ . '/../skipif_root.inc'; 6?> 7--FILE-- 8<?php 9/* Prototype: bool is_readable ( string $filename ); 10 Description: Tells whether the filename is readable. 11*/ 12 13/* test is_readable() with file having different filepath notation */ 14 15require __DIR__.'/file.inc'; 16echo "*** Testing is_readable(): usage variations ***\n"; 17 18$file_path = __DIR__; 19mkdir("$file_path/is_readable_variation1"); 20 21// create a new temporary file 22$fp = fopen("$file_path/is_readable_variation1/bar.tmp", "w"); 23fclose($fp); 24 25/* array of files to be tested if they are readable by using 26 is_readable() function */ 27$files_arr = array( 28 "$file_path/is_readable_variation1/bar.tmp", 29 30 /* Testing a file trailing slash */ 31 "$file_path/is_readable_variation1/bar.tmp/", 32 33 /* Testing file with double slashes */ 34 "$file_path/is_readable_variation1//bar.tmp", 35 "$file_path//is_readable_variation1//bar.tmp", 36 "$file_path/is_readable_variation1/*.tmp", 37 "$file_path/is_readable_variation1/b*.tmp", 38 39 /* Testing Binary safe */ 40 "$file_path/is_readable_variation1".chr(0)."bar.tmp", 41 "$file_path".chr(0)."is_readable_variation1/bar.tmp", 42 "$file_path".chr(0)."is_readable_variation1/bar.tmp", 43 44 /* Testing directories */ 45 ".", // current directory, exp: bool(true) 46 "$file_path/is_readable_variation1" // temp directory, exp: bool(true) 47); 48$counter = 1; 49/* loop through to test each element in the above array 50 is a writable file */ 51foreach($files_arr as $file) { 52 echo "-- Iteration $counter --\n"; 53 var_dump( is_readable($file) ); 54 $counter++; 55 clearstatcache(); 56} 57 58echo "Done\n"; 59?> 60--CLEAN-- 61<?php 62unlink(__DIR__."/is_readable_variation1/bar.tmp"); 63rmdir(__DIR__."/is_readable_variation1/"); 64?> 65--EXPECTF-- 66*** Testing is_readable(): usage variations *** 67-- Iteration 1 -- 68bool(true) 69-- Iteration 2 -- 70bool(%s) 71-- Iteration 3 -- 72bool(true) 73-- Iteration 4 -- 74bool(true) 75-- Iteration 5 -- 76bool(false) 77-- Iteration 6 -- 78bool(false) 79-- Iteration 7 -- 80 81Warning: is_readable() expects parameter 1 to be a valid path, string given in %s on line %d 82NULL 83-- Iteration 8 -- 84 85Warning: is_readable() expects parameter 1 to be a valid path, string given in %s on line %d 86NULL 87-- Iteration 9 -- 88 89Warning: is_readable() expects parameter 1 to be a valid path, string given in %s on line %d 90NULL 91-- Iteration 10 -- 92bool(true) 93-- Iteration 11 -- 94bool(true) 95Done 96