1--TEST-- 2Test lstat() and stat() functions: error conditions 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 18echo "*** Testing lstat() for error conditions ***\n"; 19$file_path = dirname(__FILE__); 20var_dump( lstat() ); // args < expected 21var_dump( lstat(__FILE__, 2) ); // args > expected 22var_dump( lstat("$file_path/temp.tmp") ); // non existing file 23var_dump( lstat(22) ); // scalar argument 24$arr = array(__FILE__); 25var_dump( lstat($arr) ); // array argument 26 27echo "\n*** Testing stat() for error conditions ***\n"; 28var_dump( stat() ); // args < expected 29var_dump( stat(__FILE__, 2) ); // file, args > expected 30var_dump( stat(dirname(__FILE__), 2) ); //dir, args > expected 31 32var_dump( stat("$file_path/temp.tmp") ); // non existing file 33var_dump( stat("$file_path/temp/") ); // non existing dir 34var_dump( stat(22) ); // scalar argument 35var_dump( stat($arr) ); // array argument 36 37echo "Done\n"; 38?> 39--EXPECTF-- 40*** Testing lstat() for error conditions *** 41 42Warning: lstat() expects exactly 1 parameter, 0 given in %s on line %d 43NULL 44 45Warning: lstat() expects exactly 1 parameter, 2 given in %s on line %d 46NULL 47 48Warning: lstat(): Lstat failed for %s in %s on line %d 49bool(false) 50 51Warning: lstat(): Lstat failed for 22 in %s on line %d 52bool(false) 53 54Warning: lstat() expects parameter 1 to be a valid path, array given in %s on line %d 55NULL 56 57*** Testing stat() for error conditions *** 58 59Warning: stat() expects exactly 1 parameter, 0 given in %s on line %d 60NULL 61 62Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d 63NULL 64 65Warning: stat() expects exactly 1 parameter, 2 given in %s on line %d 66NULL 67 68Warning: stat(): stat failed for %s in %s on line %d 69bool(false) 70 71Warning: stat(): stat failed for %s in %s on line %d 72bool(false) 73 74Warning: stat(): stat failed for 22 in %s on line %d 75bool(false) 76 77Warning: stat() expects parameter 1 to be a valid path, array given in %s on line %d 78NULL 79Done 80