1--TEST-- 2Test lstat() and stat() functions: usage variations - link names stored in array/object 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) == 'WIN') { 6 die('skip.. lstat() not available on Windows'); 7} 8?> 9--FILE-- 10<?php 11/* Prototype: array lstat ( string $filename ); 12 Description: Gives information about a file or symbolic link 13 14 Prototype: array stat ( string $filename ); 15 Description: Gives information about a file 16*/ 17 18/* test for stats of link when their names are stored in object and array */ 19 20$file_path = dirname(__FILE__); 21require "$file_path/file.inc"; 22 23$fp = fopen("$file_path/lstat_stat_variation20.tmp", "w"); // temp file 24fclose($fp); 25 26// temp link 27symlink("$file_path/lstat_stat_variation20.tmp", "$file_path/lstat_stat_variation20_link.tmp"); 28 29echo "*** Testing lstat() with linkname stored inside an object/array ***\n"; 30class names { 31 public $var_name; 32 public function __construct($name) { 33 $this->var_name = $name; 34 } 35} 36 37// link name stored in an object 38$link_object = new names("$file_path/lstat_stat_variation20_link.tmp"); 39 40// link name stored in side an array 41// with default numeric key 42$link_array = array("$file_path/lstat_stat_variation20_link.tmp"); 43 44// with string key index 45$link_array_with_key = array("linkname" => "$file_path/lstat_stat_variation20_link.tmp"); 46 47echo "\n-- Testing lstat() on link name stored inside an object --\n"; 48var_dump( lstat($link_object->var_name) ); 49 50echo "\n-- Testing stat() on link name stored inside an array --\n"; 51var_dump( stat($link_array[0]) ); // with default numeric index 52var_dump( stat($link_array_with_key["linkname"]) ); // with string key 53var_dump( stat($link_array_with_key['linkname']) ); 54 55echo "\n--- Done ---"; 56?> 57--CLEAN-- 58<?php 59$file_path = dirname(__FILE__); 60unlink("$file_path/lstat_stat_variation20_link.tmp"); 61unlink("$file_path/lstat_stat_variation20.tmp"); 62?> 63--EXPECTF-- 64*** Testing lstat() with linkname stored inside an object/array *** 65 66-- Testing lstat() on link name stored inside an object -- 67array(26) { 68 [0]=> 69 int(%d) 70 [1]=> 71 int(%d) 72 [2]=> 73 int(%d) 74 [3]=> 75 int(%d) 76 [4]=> 77 int(%d) 78 [5]=> 79 int(%d) 80 [6]=> 81 int(%d) 82 [7]=> 83 int(%d) 84 [8]=> 85 int(%d) 86 [9]=> 87 int(%d) 88 [10]=> 89 int(%d) 90 [11]=> 91 int(%d) 92 [12]=> 93 int(%d) 94 ["dev"]=> 95 int(%d) 96 ["ino"]=> 97 int(%d) 98 ["mode"]=> 99 int(%d) 100 ["nlink"]=> 101 int(%d) 102 ["uid"]=> 103 int(%d) 104 ["gid"]=> 105 int(%d) 106 ["rdev"]=> 107 int(%d) 108 ["size"]=> 109 int(%d) 110 ["atime"]=> 111 int(%d) 112 ["mtime"]=> 113 int(%d) 114 ["ctime"]=> 115 int(%d) 116 ["blksize"]=> 117 int(%d) 118 ["blocks"]=> 119 int(%d) 120} 121 122-- Testing stat() on link name stored inside an array -- 123array(26) { 124 [0]=> 125 int(%d) 126 [1]=> 127 int(%d) 128 [2]=> 129 int(%d) 130 [3]=> 131 int(%d) 132 [4]=> 133 int(%d) 134 [5]=> 135 int(%d) 136 [6]=> 137 int(%d) 138 [7]=> 139 int(%d) 140 [8]=> 141 int(%d) 142 [9]=> 143 int(%d) 144 [10]=> 145 int(%d) 146 [11]=> 147 int(%d) 148 [12]=> 149 int(%d) 150 ["dev"]=> 151 int(%d) 152 ["ino"]=> 153 int(%d) 154 ["mode"]=> 155 int(%d) 156 ["nlink"]=> 157 int(%d) 158 ["uid"]=> 159 int(%d) 160 ["gid"]=> 161 int(%d) 162 ["rdev"]=> 163 int(%d) 164 ["size"]=> 165 int(%d) 166 ["atime"]=> 167 int(%d) 168 ["mtime"]=> 169 int(%d) 170 ["ctime"]=> 171 int(%d) 172 ["blksize"]=> 173 int(%d) 174 ["blocks"]=> 175 int(%d) 176} 177array(26) { 178 [0]=> 179 int(%d) 180 [1]=> 181 int(%d) 182 [2]=> 183 int(%d) 184 [3]=> 185 int(%d) 186 [4]=> 187 int(%d) 188 [5]=> 189 int(%d) 190 [6]=> 191 int(%d) 192 [7]=> 193 int(%d) 194 [8]=> 195 int(%d) 196 [9]=> 197 int(%d) 198 [10]=> 199 int(%d) 200 [11]=> 201 int(%d) 202 [12]=> 203 int(%d) 204 ["dev"]=> 205 int(%d) 206 ["ino"]=> 207 int(%d) 208 ["mode"]=> 209 int(%d) 210 ["nlink"]=> 211 int(%d) 212 ["uid"]=> 213 int(%d) 214 ["gid"]=> 215 int(%d) 216 ["rdev"]=> 217 int(%d) 218 ["size"]=> 219 int(%d) 220 ["atime"]=> 221 int(%d) 222 ["mtime"]=> 223 int(%d) 224 ["ctime"]=> 225 int(%d) 226 ["blksize"]=> 227 int(%d) 228 ["blocks"]=> 229 int(%d) 230} 231array(26) { 232 [0]=> 233 int(%d) 234 [1]=> 235 int(%d) 236 [2]=> 237 int(%d) 238 [3]=> 239 int(%d) 240 [4]=> 241 int(%d) 242 [5]=> 243 int(%d) 244 [6]=> 245 int(%d) 246 [7]=> 247 int(%d) 248 [8]=> 249 int(%d) 250 [9]=> 251 int(%d) 252 [10]=> 253 int(%d) 254 [11]=> 255 int(%d) 256 [12]=> 257 int(%d) 258 ["dev"]=> 259 int(%d) 260 ["ino"]=> 261 int(%d) 262 ["mode"]=> 263 int(%d) 264 ["nlink"]=> 265 int(%d) 266 ["uid"]=> 267 int(%d) 268 ["gid"]=> 269 int(%d) 270 ["rdev"]=> 271 int(%d) 272 ["size"]=> 273 int(%d) 274 ["atime"]=> 275 int(%d) 276 ["mtime"]=> 277 int(%d) 278 ["ctime"]=> 279 int(%d) 280 ["blksize"]=> 281 int(%d) 282 ["blocks"]=> 283 int(%d) 284} 285 286--- Done --- 287