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