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