Parse error: syntax error, unexpected T_STATIC in D:\PHPnow\htdocs\tj.php on line 13
出错了大家帮我看下怎么回事<?
class sundry
{
   function total_size($dir)
   {
       $filepoint = opendir($dir       static $total_size;
       while($file = readdir($filepoint))
       {
           if($file=="."||$file=="..")continue;
           $target = "$dir/$file";
           if(is_dir($target))
           {
               $this->total_size($target           }
           else
           {
               $total_size+= filesize($target           }
       }
       return $total_size;
   }
   function size_show($dir)
   {
       $total_size = $this->total_size($dir       if($total_size<"1024")
           $size_show = ($total_size*8)." byte";
       if($total_size>"1024"&&$total_size<"1048576")
           $size_show = sprintf("%1.2f",($total_size/1024))." K";
       if($total_size>"1048576")
           $size_show = sprintf("%1.2f",($total_size/1048576))." M";
       return $size_show;
   }
}
//============
//使用方法
//============
$sundry = new sundry;
//test为你要计算大小的目录
$size = $sundry->size_show("news");echo $size;
?>

解决方案 »

  1.   

    楼主复制代码都有漏掉的,我把你漏的括号和分号补上后没有发现有什么错误<?
    class sundry
    {
    function total_size($dir)
    {
    $filepoint = opendir($dir); static $total_size;
    while($file = readdir($filepoint))
    {
    if($file=="."||$file=="..")continue;
    $target = "$dir/$file";
    if(is_dir($target))
    {
    $this->total_size($target); }
    else
    {
    $total_size+= filesize($target); }
    }
    return $total_size;
    }
    function size_show($dir)
    {
    $total_size = $this->total_size($dir); if($total_size<"1024")
    $size_show = ($total_size*8)." byte";
    if($total_size>"1024"&&$total_size<"1048576")
    $size_show = sprintf("%1.2f",($total_size/1024))." K";
    if($total_size>"1048576")
    $size_show = sprintf("%1.2f",($total_size/1048576))." M";
    return $size_show;
    }
    }
    //============
    //使用方法
    //============
    $sundry = new sundry;
    //test为你要计算大小的目录
    $size = $sundry->size_show("../images");echo $size;
    ?>得到结果:1.24 M