1--TEST-- 2Test fileperms() function: usage variations - diff. path notations 3--CREDITS-- 4Dave Kelsey <d_kelsey@uk.ibm.com> 5--FILE-- 6<?php 7/* Passing file names with different notations, using slashes, wild-card chars */ 8 9$file_path = __DIR__; 10 11echo "*** Testing fileperms() with different notations of file names ***\n"; 12$dir_name = $file_path."/fileperms_variation3"; 13mkdir($dir_name); 14$file_handle = fopen($dir_name."/fileperms_variation3.tmp", "w"); 15fclose($file_handle); 16 17$files_arr = array( 18 "/fileperms_variation3/fileperms_variation3.tmp", 19 20 /* Testing a file trailing slash */ 21 "/fileperms_variation3/fileperms_variation3.tmp/", 22 23 /* Testing file with double slashes */ 24 "/fileperms_variation3//fileperms_variation3.tmp", 25 "//fileperms_variation3//fileperms_variation3.tmp", 26 "/fileperms_variation3/*.tmp", 27 "fileperms_variation3/fileperms*.tmp", 28 29 /* Testing Binary safe */ 30 "/fileperms_variation3/fileperms_variation3.tmp".chr(0), 31 "/fileperms_variation3/fileperms_variation3.tmp\0" 32); 33 34$count = 1; 35/* loop through to test each element in the above array */ 36foreach($files_arr as $file) { 37 echo "- Iteration $count -\n"; 38 try { 39 var_dump( fileperms( $file_path."/".$file ) ); 40 } catch (Error $e) { 41 echo $e->getMessage(), "\n"; 42 } 43 clearstatcache(); 44 $count++; 45} 46 47echo "\n*** Done ***"; 48?> 49--CLEAN-- 50<?php 51$file_path = __DIR__; 52$dir_name = $file_path."/fileperms_variation3"; 53unlink($dir_name."/fileperms_variation3.tmp"); 54rmdir($dir_name); 55?> 56--EXPECTF-- 57*** Testing fileperms() with different notations of file names *** 58- Iteration 1 - 59int(%d) 60- Iteration 2 - 61 62Warning: fileperms(): stat failed for %s//fileperms_variation3/fileperms_variation3.tmp/ in %s on line %d 63bool(false) 64- Iteration 3 - 65int(%d) 66- Iteration 4 - 67int(%d) 68- Iteration 5 - 69 70Warning: fileperms(): stat failed for %s//fileperms_variation3/*.tmp in %s on line %d 71bool(false) 72- Iteration 6 - 73 74Warning: fileperms(): stat failed for %s/fileperms_variation3/fileperms*.tmp in %s on line %d 75bool(false) 76- Iteration 7 - 77 78Warning: fileperms(): Filename contains null byte in %s on line %d 79bool(false) 80- Iteration 8 - 81 82Warning: fileperms(): Filename contains null byte in %s on line %d 83bool(false) 84 85*** Done *** 86