1--TEST-- 2Test dir() function : usage variations - non-existent directory 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/* 12 * Prototype : object dir(string $directory[, resource $context]) 13 * Description: Directory class with properties, handle and class and methods read, rewind and close 14 * Source code: ext/standard/dir.c 15 */ 16 17/* 18 * Passing a non-existent directory as argument to dir() function 19 * and checking to see if proper warning message is output. 20 */ 21echo "*** Testing dir() : open a non-existent directory ***\n"; 22 23// create the temporary directory 24$file_path = dirname(__FILE__); 25$dir_path = $file_path."/dir_variation6"; 26@mkdir($dir_path); 27 28// open existent directory 29$d = dir($dir_path); 30$d->close(); //close the dir 31 32// remove directory and try to open the same(non-existent) directory again 33rmdir($dir_path); 34clearstatcache(); 35 36echo "-- opening previously removed directory --\n"; 37var_dump( dir($dir_path) ); 38 39// point to a non-existent directory 40$non_existent_dir = $file_path."/non_existent_dir"; 41echo "-- opening non-existent directory --\n"; 42$d = dir($non_existent_dir); 43var_dump( $d ); 44 45echo "Done"; 46?> 47--EXPECTF-- 48*** Testing dir() : open a non-existent directory *** 49-- opening previously removed directory -- 50 51Warning: dir(%s): failed to open dir: %s in %s on line %d 52bool(false) 53-- opening non-existent directory -- 54 55Warning: dir(%s): failed to open dir: %s in %s on line %d 56bool(false) 57Done 58