当前位置:编程学习 > php >>

PHP返回值出了点问题。。。

这段代码是计算一个文件夹里所有文件的总大小的。

为什么在returrn处把$count这个值计算除以两个1024会和在外面除以两个1024值不一样?

<?php
class globb{
function demo_file($file){
$glob = glob($file.'\\*');
foreach($glob as $val){
if(is_dir($val)){
$cound += $this->demo_file($val);

 }
else{
$cound += filesize($val);
 }

   }
return $cound;

       }


   }


$demo = new globb();
echo $demo->demo_file('.')/pow(1024,2);
?>

 

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,