ok, i been mucking around with php for a while for school.
i've attempted to write a function that gets the size of folders.
can someone tell me whats wrong with it. i know calling the same function i am in is dodgy but i cant think of another way unless i copy the function again with a different name..
this current code doesent work ><
code:
<?
function foldersize ($folder){
$handle = opendir($folder);
if ($handle = opendir($folder)) {
while (false !== ($file = readdir($handle))) {
if($file !='.' && $file !='' && $file != '../'){
if (is_dir($folder.'/'.$file)){
$temp2 = $temp2 . "$folder/$file";
$foldersize = $foldersize + foldersize("$folder/$file");
}else{
$temp = $temp . "<b>File</b>: $folder/$file<br>";
$foldersize = $foldersize + filesize("$folder/$file");
}
}
}
}
closedir($handle);
clearstatcache();
$foldersize = truesize($foldersize);
//echo $temp;
//echo "$temp2 <br>";
return $foldersize;
}
?>