1--TEST-- 2Test lstat() and stat() functions: usage variations - dir/file name stored in object 3--FILE-- 4<?php 5/* Prototype: array lstat ( string $filename ); 6 Description: Gives information about a file or symbolic link 7 8 Prototype: array stat ( string $filename ); 9 Description: Gives information about a file 10*/ 11 12/* test for stats of dir/file when their names are stored in objects */ 13 14$file_path = __DIR__; 15require "$file_path/file.inc"; 16 17 18/* create temp file and directory */ 19mkdir("$file_path/lstat_stat_variation18/"); // temp dir 20$fp = fopen("$file_path/lstat_stat_variation18.tmp", "w"); // temp file 21fclose($fp); 22 23echo "*** Testing stat() with filename & directory name stored inside an object ***\n"; 24 25class names { 26 public $var_name; 27 public function __construct($name) { 28 $this->var_name = $name; 29 } 30} 31 32// directory name stored in an object 33$dir_name = new names("$file_path/lstat_stat_variation18"); 34 35// file name stored in an object 36$file_name = new names("$file_path/lstat_stat_variation18.tmp"); 37 38echo "\n-- Testing stat() on filename stored inside an object --\n"; 39// dump the stat returned value 40var_dump( stat($file_name->var_name) ); 41 42echo "\n-- Testing stat() on directory name stored inside an object --\n"; 43// dump the stat returned value 44var_dump( stat($dir_name->var_name) ); 45 46echo "\n--- Done ---"; 47?> 48--CLEAN-- 49<?php 50$file_path = __DIR__; 51unlink("$file_path/lstat_stat_variation18.tmp"); 52rmdir("$file_path/lstat_stat_variation18"); 53?> 54--EXPECTF-- 55*** Testing stat() with filename & directory name stored inside an object *** 56 57-- Testing stat() on filename stored inside an object -- 58array(26) { 59 [0]=> 60 int(%i) 61 [1]=> 62 int(%d) 63 [2]=> 64 int(%d) 65 [3]=> 66 int(%d) 67 [4]=> 68 int(%d) 69 [5]=> 70 int(%d) 71 [6]=> 72 int(%d) 73 [7]=> 74 int(%d) 75 [8]=> 76 int(%d) 77 [9]=> 78 int(%d) 79 [10]=> 80 int(%d) 81 [11]=> 82 int(%i) 83 [12]=> 84 int(%i) 85 ["dev"]=> 86 int(%i) 87 ["ino"]=> 88 int(%d) 89 ["mode"]=> 90 int(%d) 91 ["nlink"]=> 92 int(%d) 93 ["uid"]=> 94 int(%d) 95 ["gid"]=> 96 int(%d) 97 ["rdev"]=> 98 int(%d) 99 ["size"]=> 100 int(%d) 101 ["atime"]=> 102 int(%d) 103 ["mtime"]=> 104 int(%d) 105 ["ctime"]=> 106 int(%d) 107 ["blksize"]=> 108 int(%i) 109 ["blocks"]=> 110 int(%i) 111} 112 113-- Testing stat() on directory name stored inside an object -- 114array(26) { 115 [0]=> 116 int(%i) 117 [1]=> 118 int(%d) 119 [2]=> 120 int(%d) 121 [3]=> 122 int(%d) 123 [4]=> 124 int(%d) 125 [5]=> 126 int(%d) 127 [6]=> 128 int(%d) 129 [7]=> 130 int(%d) 131 [8]=> 132 int(%d) 133 [9]=> 134 int(%d) 135 [10]=> 136 int(%d) 137 [11]=> 138 int(%i) 139 [12]=> 140 int(%i) 141 ["dev"]=> 142 int(%i) 143 ["ino"]=> 144 int(%d) 145 ["mode"]=> 146 int(%d) 147 ["nlink"]=> 148 int(%d) 149 ["uid"]=> 150 int(%d) 151 ["gid"]=> 152 int(%d) 153 ["rdev"]=> 154 int(%d) 155 ["size"]=> 156 int(%d) 157 ["atime"]=> 158 int(%d) 159 ["mtime"]=> 160 int(%d) 161 ["ctime"]=> 162 int(%d) 163 ["blksize"]=> 164 int(%i) 165 ["blocks"]=> 166 int(%i) 167} 168 169--- Done --- 170