1--TEST-- 2Test stat() functions: usage variations - effects of is_dir() & is_file() 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) != 'WIN') { 6 die('skip.. only for Windows'); 7} 8?> 9--FILE-- 10<?php 11 12/* 13 * Prototype: array stat ( string $filename ); 14 * Description: Gives information about a file 15 */ 16 17/* test the effects on the stats of dir/file for using is_dir() & is_file() on dir/file */ 18 19$file_path = dirname(__FILE__); 20require "$file_path/file.inc"; 21 22 23/* create temp file and directory */ 24mkdir("$file_path/stat_variation4/"); // temp dir 25 26$file_handle = fopen("$file_path/stat_variation4.tmp", "w"); // temp file 27fclose($file_handle); 28 29 30echo "\n*** Testing stat(): on file and directory after accessing it 31 with is_dir() and is_file() functions ***\n"; 32 33// is_dir() on a directory 34echo "-- Testing on Directory --\n"; 35$old_dirname = "$file_path/stat_variation4"; 36$old_stat = stat($old_dirname); 37// clear the cache 38clearstatcache(); 39sleep(2); 40var_dump( is_dir($old_dirname) ); 41$new_stat = stat($old_dirname); 42 43// compare self stats 44var_dump( compare_self_stat($old_stat) ); 45var_dump( compare_self_stat($new_stat) ); 46// compare the stat 47var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys, "=") ); 48// clear the stat 49clearstatcache(); 50 51 52// is_file() on a file 53echo "-- Testing on file --\n"; 54$old_filename = "$file_path/stat_variation4.tmp"; 55$old_stat = stat($old_filename); 56// clear the stat 57clearstatcache(); 58sleep(2); 59var_dump( is_file($old_filename) ); 60$new_stat = stat($old_filename); 61// compare self stats 62var_dump( compare_self_stat($old_stat) ); 63var_dump( compare_self_stat($new_stat) ); 64// compare the stat 65var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys, "=") ); 66// clear the stat 67clearstatcache(); 68 69echo "\n*** Done ***"; 70?> 71 72--CLEAN-- 73<?php 74$file_path = dirname(__FILE__); 75unlink("$file_path/stat_variation4.tmp"); 76rmdir("$file_path/stat_variation4"); 77?> 78--EXPECTF-- 79*** Testing stat(): on file and directory after accessing it 80 with is_dir() and is_file() functions *** 81-- Testing on Directory -- 82bool(true) 83bool(true) 84bool(true) 85bool(true) 86-- Testing on file -- 87bool(true) 88bool(true) 89bool(true) 90bool(true) 91 92*** Done *** 93 94