Home » PHP » PHP in determining directory size related question...

PHP in determining directory size related questions code

< PHP?
Function directory_size ($address) //address incoming file path
{
$size=0; / / initialize file size variables
If ($dir=@opendir ($address) ) / / if the normal open file for the next operation
{
While ($filename=readdir ($dir) )
{
If ($filename, =,..., &&$filename, =,..., )
{
If (is_file ($address. \ \, .$filename) )
{
$size+=filesize ($address. \ \ .$filename) ;
}
If (is_dir ($address. \ \, .$filename) )
{
$size+=directory_size ($address. \ \ .$filename) ;
}
}
}
}
@closedir ($dir) ;
Return $size;
}
$dire_address= "F:course" ;
$totalsize=directory_size ($dire_address) ;
Printf (,%s, , $totalsize) ;
>
?

explains @: hide the output of error by adding "@" to the function "
"
Opdendir: opens the directory handle

Readdir: returns the entry
in the directory handle opened by opendir ()
Is_file: determines whether the file is

Is_dir: determines whether directory

is available

experimental environment: Windows 10 operating system

Eclipse, for, PHP, Developers (Mars)

WampServer Version2.4


Latest