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