2
Test lstat() and stat() functions: usage variations - dir/file names in array
5
if (substr(PHP_OS, 0, 3) == 'WIN') {
6
die('skip.. Not valid for Windows');
11
/* Prototype: array lstat ( string $filename );
12
Description: Gives information about a file or symbolic link
14
Prototype: array stat ( string $filename );
15
Description: Gives information about a file
18
/* test for stats of dir/file when their names are stored in an array */
20
$file_path = dirname(__FILE__);
21
require "$file_path/file.inc";
24
/* create temp file, link and directory */
25
@rmdir("$file_path/lstat_stat_variation19"); // ensure that dir doesn't exists
26
mkdir("$file_path/lstat_stat_variation19"); // temp dir
28
$fp = fopen("$file_path/lstat_stat_variation19.tmp", "w"); // temp file
31
echo "*** Testing stat() with filename & directory name stored inside an array ***\n";
33
// array with default numeric index
35
"$file_path/lstat_stat_variation19.tmp",
36
"$file_path/lstat_stat_variation19"
39
//array with string key index
40
$names_with_key = array (
41
'file' => "$file_path/lstat_stat_variation19.tmp",
42
"dir" => "$file_path/lstat_stat_variation19"
45
echo "\n-- Testing stat() on filename stored inside an array --\n";
46
var_dump( stat($names[0]) ); // values stored with numeric index
47
var_dump( stat($names_with_key['file']) ); // value stored with string key
49
echo "\n-- Testing stat() on dir name stored inside an array --\n";
50
var_dump( stat($names[1]) ); // values stored with numeric index
51
var_dump( stat($names_with_key["dir"]) ); // value stored with string key
53
echo "\n--- Done ---";
58
$file_path = dirname(__FILE__);
59
unlink("$file_path/lstat_stat_variation19.tmp");
60
rmdir("$file_path/lstat_stat_variation19");
63
*** Testing stat() with filename & directory name stored inside an array ***
65
-- Testing stat() on filename stored inside an array --
175
-- Testing stat() on dir name stored inside an array --