Return to 005_variation2-win32.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test fileatime(), filemtime(), filectime() & touch() functions : usage variation 3: --CREDITS-- 4: Dave Kelsey <d_kelsey@uk.ibm.com> 5: --SKIPIF-- 6: <?php 7: if (substr(PHP_OS, 0, 3) != 'WIN') { 8: die('skip.. only for Windows'); 9: } 10: ?> 11: --FILE-- 12: <?php 13: /* 14: Prototype: int fileatime ( string $filename ); 15: Description: Returns the time the file was last accessed, or FALSE 16: in case of an error. The time is returned as a Unix timestamp. 17: 18: Prototype: int filemtime ( string $filename ); 19: Description: Returns the time the file was last modified, or FALSE 20: in case of an error. 21: 22: Prototype: int filectime ( string $filename ); 23: Description: Returns the time the file was last changed, or FALSE 24: in case of an error. The time is returned as a Unix timestamp. 25: 26: Prototype: bool touch ( string $filename [, int $time [, int $atime]] ); 27: Description: Attempts to set the access and modification times of the file 28: named in the filename parameter to the value given in time. 29: */ 30: 31: /* 32: Prototype: void stat_fn(string $filename); 33: Description: Prints access, modification and change times of a file 34: */ 35: function stat_fn( $filename ) { 36: echo "\n-- File '$filename' --\n"; 37: echo "-- File access time is => "; 38: echo fileatime($filename)."\n"; 39: clearstatcache(); 40: echo "-- File modification time is => "; 41: echo filemtime($filename)."\n"; 42: clearstatcache(); 43: echo "-- inode change time is => "; 44: echo filectime($filename)."\n"; 45: clearstatcache(); 46: 47: 48: } 49: 50: echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n"; 51: echo "\n*** testing file info ***"; 52: stat_fn(NULL); 53: stat_fn(false); 54: stat_fn(''); 55: stat_fn(' '); 56: stat_fn('|'); 57: echo "\n*** testing touch ***"; 58: var_dump(touch(NULL)); 59: var_dump(touch(false)); 60: var_dump(touch('')); 61: 62: //php generates permission denied, we generate No such file or dir. 63: var_dump(touch(' ')); 64: var_dump(touch('|')); 65: 66: 67: echo "Done"; 68: ?> 69: --EXPECTF-- 70: *** Testing fileattime(), filemtime(), filectime() & touch() : usage variations *** 71: 72: *** testing file info *** 73: -- File '' -- 74: -- File access time is => 75: -- File modification time is => 76: -- inode change time is => 77: 78: -- File '' -- 79: -- File access time is => 80: -- File modification time is => 81: -- inode change time is => 82: 83: -- File '' -- 84: -- File access time is => 85: -- File modification time is => 86: -- inode change time is => 87: 88: -- File ' ' -- 89: -- File access time is => 90: Warning: fileatime(): stat failed for in %s on line %d 91: 92: -- File modification time is => 93: Warning: filemtime(): stat failed for in %s on line %d 94: 95: -- inode change time is => 96: Warning: filectime(): stat failed for in %s on line %d 97: 98: 99: -- File '|' -- 100: -- File access time is => 101: Warning: fileatime(): stat failed for | in %s on line %d 102: 103: -- File modification time is => 104: Warning: filemtime(): stat failed for | in %s on line %d 105: 106: -- inode change time is => 107: Warning: filectime(): stat failed for | in %s on line %d 108: 109: 110: *** testing touch *** 111: Warning: touch(): %s in %s on line %d 112: bool(false) 113: 114: Warning: touch(): %s in %s on line %d 115: bool(false) 116: 117: Warning: touch(): %s in %s on line %d 118: bool(false) 119: 120: Warning: touch(): %s in %s on line %d 121: bool(false) 122: 123: Warning: touch(): %s in %s on line %d 124: bool(false) 125: Done