3 * Prototype: float disk_free_space( string directory )
4 * Description: Given a string containing a directory, this function
5 * will return the number of bytes available on the corresponding
6 * filesystem or disk partition
9 $file_path = dirname(__FILE__
);
11 echo "*** Testing with a directory ***\n";
12 var_dump( disk_free_space($file_path."/..") );
13 var_dump( diskfreespace($file_path."/..") );
15 echo "\nTesting for the return type ***\n";
16 $return_value = disk_free_space($file_path);
17 var_dump( is_float($return_value) );
19 echo "\n*** Testing with different directory combinations ***";
20 $dir = "/disk_free_space";
21 mkdir($file_path.$dir);
28 /* Testing a file trailing slash */
29 $file_path."".$dir."/",
30 $file_path."/.".$dir."/",
32 /* Testing file with double trailing slashes */
34 $file_path."/.".$dir."//",
35 $file_path."/./".$dir."//",
37 /* Testing Binary safe */
38 $file_path.$dir.chr(0),
39 $file_path."/.".$dir.chr(0),
40 ".".chr(0).$file_path.$dir,
41 ".".chr(0).$file_path.$dir.chr(0)
45 /* loop through to test each element the above array */
46 foreach($dirs_arr as $dir1) {
47 echo "\n-- Iteration $count --\n";
48 var_dump( disk_free_space( $dir1 ) );
49 var_dump( diskfreespace( $dir1 ) );
56 $file_path = dirname(__FILE__
);
57 rmdir($file_path."/disk_free_space");