1--TEST-- 2Test closedir() function : usage variations - close a file pointer 3--FILE-- 4<?php 5/* 6 * Create a file pointer using fopen() then try to close it using closedir() 7 */ 8 9echo "*** Testing closedir() : usage variations ***\n"; 10 11echo "\n-- Open a file using fopen() --\n"; 12var_dump($fp = fopen(__FILE__, 'r')); 13 14echo "\n-- Try to close the file pointer using closedir() --\n"; 15try { 16 var_dump(closedir($fp)); 17} catch (\TypeError $e) { 18 echo $e->getMessage() . "\n"; 19} 20echo "\n-- Check file pointer: --\n"; 21var_dump($fp); 22 23if(is_resource($fp)) { 24 fclose($fp); 25} 26?> 27--EXPECTF-- 28*** Testing closedir() : usage variations *** 29 30-- Open a file using fopen() -- 31resource(%d) of type (stream) 32 33-- Try to close the file pointer using closedir() -- 34closedir(): Argument #1 ($dir_handle) must be a valid Directory resource 35 36-- Check file pointer: -- 37resource(%d) of type (stream) 38