$comment=$comment[0];
是取的左边的第一位还中右边的第一位啊?!

解决方案 »

  1.   

    <?php
    $fname="count.dat";
    $date=date('Ymd');
    if (file_exists($fname)){
    $comment = file($fname);
     $fp=fopen($fname,w);
             if($date==substr($comment[0],0,8))
             {
     
      $comment_ok=$date.substr(++$comment[0],-4);
             } else {
      $comment_ok=$date.'0001';
             }
    fwrite($fp,$comment_ok);
    } else {
    $fp=fopen($fname,w);
    fwrite($fp,$date.'0001');
    $comment_ok=$date.'0001';
    }
    fclose($fp);
     echo $comment_ok;
    ?>