Return to is_file_variation4.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test is_file() function: usage variations - diff. path notations (Bug #42027) 3: --FILE-- 4: <?php 5: /* Prototype: bool is_file ( string $filename ); 6: Description: Tells whether the filename is a regular file 7: Returns TRUE if the filename exists and is a regular file 8: */ 9: 10: /* Passing file names with different notations, using slashes, wild-card chars */ 11: 12: $file_path = dirname(__FILE__); 13: 14: echo "*** Testing is_file() with different notations of file names ***\n"; 15: $dir_name = $file_path."/is_file_variation4"; 16: mkdir($dir_name); 17: $file_handle = fopen($dir_name."/is_file_variation4.tmp", "w"); 18: fclose($file_handle); 19: 20: $files_arr = array( 21: "/is_file_variation4/is_file_variation4.tmp", 22: 23: /* Testing a file trailing slash */ 24: "/is_file_variation4/is_file_variation4.tmp/", 25: 26: /* Testing file with double slashes */ 27: "/is_file_variation4//is_file_variation4.tmp", 28: "//is_file_variation4//is_file_variation4.tmp", 29: "/is_file_variation4/*.tmp", 30: "is_file_variation4/is_file*.tmp", 31: 32: /* Testing Binary safe */ 33: "/is_file_variation4/is_file_variation4.tmp".chr(0), 34: "/is_file_variation4/is_file_variation4.tmp\0" 35: ); 36: 37: $count = 1; 38: /* loop through to test each element in the above array */ 39: foreach($files_arr as $file) { 40: echo "- Iteration $count -\n"; 41: var_dump( is_file( $file_path."/".$file ) ); 42: clearstatcache(); 43: $count++; 44: } 45: 46: echo "\n*** Done ***"; 47: ?> 48: --CLEAN-- 49: <?php 50: $file_path = dirname(__FILE__); 51: $dir_name = $file_path."/is_file_variation4"; 52: unlink($dir_name."/is_file_variation4.tmp"); 53: rmdir($dir_name); 54: ?> 55: --EXPECTF-- 56: *** Testing is_file() with different notations of file names *** 57: - Iteration 1 - 58: bool(true) 59: - Iteration 2 - 60: bool(false) 61: - Iteration 3 - 62: bool(true) 63: - Iteration 4 - 64: bool(true) 65: - Iteration 5 - 66: bool(false) 67: - Iteration 6 - 68: bool(false) 69: - Iteration 7 - 1.1.1.2 ! misho 70: ! 71: Warning: is_file() expects parameter 1 to be a valid path, string given in %s on line %d ! 72: NULL 1.1 misho 73: - Iteration 8 - 1.1.1.2 ! misho 74: ! 75: Warning: is_file() expects parameter 1 to be a valid path, string given in %s on line %d ! 76: NULL 1.1 misho 77: 78: *** Done ***