1--TEST--
2Test fileatime(), filemtime(), filectime() & touch() functions : usage variation
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if (substr(PHP_OS, 0, 3) == 'WIN') {
8    die('skip.. only for Non Windows Systems');
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*/
35function 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
50echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n";
51echo "\n*** testing touch ***\n";
52$a = touch(NULL);
53$b = touch(false);
54$c = touch('');
55$d = touch(' ');
56$e = touch('|');
57
58var_dump($a);
59var_dump($b);
60var_dump($c);
61var_dump($d);
62var_dump($e);
63
64echo "\n*** testing file info ***";
65stat_fn(NULL);
66stat_fn(false);
67stat_fn('');
68stat_fn(' ');
69stat_fn('|');
70
71var_dump(unlink(' '));
72var_dump(unlink('|'));
73
74echo "Done";
75?>
76--EXPECTF--
77*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***
78
79*** testing touch ***
80bool(false)
81bool(false)
82bool(false)
83bool(true)
84bool(true)
85
86*** testing file info ***
87-- File '' --
88-- File access time is =>
89-- File modification time is =>
90-- inode change time is =>
91
92-- File '' --
93-- File access time is =>
94-- File modification time is =>
95-- inode change time is =>
96
97-- File '' --
98-- File access time is =>
99-- File modification time is =>
100-- inode change time is =>
101
102-- File ' ' --
103-- File access time is => %d
104-- File modification time is => %d
105-- inode change time is => %d
106
107-- File '|' --
108-- File access time is => %d
109-- File modification time is => %d
110-- inode change time is => %d
111bool(true)
112bool(true)
113Done
114