xref: /PHP-5.4/ext/standard/tests/file/005_basic.phpt (revision f552f916)
1--TEST--
2Test fileatime(), filemtime(), filectime() & touch() functions : basic functionality
3--FILE--
4<?php
5/*
6   Prototype: int fileatime ( string $filename );
7   Description: Returns the time the file was last accessed, or FALSE
8     in case of an error. The time is returned as a Unix timestamp.
9
10   Prototype: int filemtime ( string $filename );
11   Description: Returns the time the file was last modified, or FALSE
12     in case of an error.
13
14   Prototype: int filectime ( string $filename );
15   Description: Returns the time the file was last changed, or FALSE
16     in case of an error. The time is returned as a Unix timestamp.
17
18   Prototype: bool touch ( string $filename [, int $time [, int $atime]] );
19   Description: Attempts to set the access and modification times of the file
20     named in the filename parameter to the value given in time.
21*/
22
23echo "*** Testing the basic functionality with file ***\n";
24print( @date('Y:M:D:H:i:s', fileatime(__FILE__)) )."\n";
25print( @date('Y:M:D:H:i:s', filemtime(__FILE__)) )."\n";
26print( @date('Y:M:D:H:i:s', filectime(__FILE__)) )."\n";
27print( @date('Y:M:D:H:i:s', touch(dirname(__FILE__)."/005_basic.tmp")) )."\n";
28
29echo "*** Testing the basic functionality with dir ***\n";
30print( @date('Y:M:D:H:i:s', fileatime(".")) )."\n";
31print( @date('Y:M:D:H:i:s', filemtime(".")) )."\n";
32print( @date('Y:M:D:H:i:s', filectime(".")) )."\n";
33print( @date('Y:M:D:H:i:s', touch(dirname(__FILE__)."/005_basic")) )."\n";
34
35echo "\n*** Done ***\n";
36?>
37--CLEAN--
38<?php
39unlink(dirname(__FILE__)."/005_basic.tmp");
40unlink(dirname(__FILE__)."/005_basic");
41?>
42--EXPECTF--
43*** Testing the basic functionality with file ***
44%d:%s:%s:%d:%d:%d
45%d:%s:%s:%d:%d:%d
46%d:%s:%s:%d:%d:%d
47%d:%s:%s:%d:%d:%d
48*** Testing the basic functionality with dir ***
49%d:%s:%s:%d:%d:%d
50%d:%s:%s:%d:%d:%d
51%d:%s:%s:%d:%d:%d
52%d:%s:%s:%d:%d:%d
53
54*** Done ***
55