这个问题应该不难!我也是初学者!
在数据库或建个文本文件存放文件名.假设filename.txt存放文件名! $fp=fopen("filename.txt","r+");//打开文件,可读写
 $imgname=fgets($fp);
 if ($imgname)
 $lasttime=str_replace(".gif","",$imgname);
 $lasttime=explode("-",$lasttime);//年-月-日-时-分-秒.gif
 $date=getdate();
 if ($lasttime[3]==$date["hours"] && $lasttime[4]==$date["minutes"]
     && $lasttime[5]==$date["seconds"]){
      if ($date["mday"]==1 && $date["mday"] != $lasttiime[2]){
      $update=true;
      }
      else if ($date["mday"] == $lasttiime[2] +1){
      $update=true;
      }
      else{
      $update=false;
      }
  }
  
  if($update){
    $imgname=$date["year"]."-".$date["mon"]."-".$date["mday"]."-".$date["hours"]."-".$date["minutes"]."-".$date["seconds"].".gif";
    fwrite($fp,$imgname);
    //图片图据装入过程
    header("content-type:image/gif");
     imagegif($image,$imgname);
     imagedestroy($image);
     echo "<img src=$imgname border=0>";
  }else {
    echo "<img src=$imgname border=0>";
  }
  fclose($fp);

解决方案 »

  1.   

    测试后通过的:if (file_exists("filename.txt")){
       $fp=fopen("filename.txt","w+");
     }else{
       $fp=fopen("filename.txt","r+");
     } $imgname=fgets($fp);
     $date=getdate(); if ($imgname){//判断是否文件名存在
       $lasttime=str_replace(".gif","",$imgname);
         $lasttime=explode("-",$lasttime);//年-月-日-时-分-秒.gif
         //判断是否文件存在24小时
         if ($lasttime[3]==$date["hours"] && $lasttime[4]==$date["minutes"]
             && $lasttime[5]==$date["seconds"]){ 
          if ($date["mday"]==1 && $date["mday"] != $lasttiime[2]){
          $update=true;
          }
          else if ($date["mday"] == $lasttiime[2] +1){
          $update=true;
          }
          else{
          $update=false;
          }
         }
     } else{
      $update=true;
     }
      if($update){
        $imgname=$date["year"]."-".$date["mon"]."-".$date["mday"]."-".$date["hours"]."-".$date["minutes"]."-".$date["seconds"].".gif";
        fwrite($fp,$imgname);
        $image=imagecreate(100,100);
        header("content-type:image/gif");
         imagegif($image,$imgname);
         imagedestroy($image);
         echo "<img src=$imgname border=0>";
      }else {
        echo "<img src=$imgname border=0>";
      }
      fclose($fp);
      

  2.   

    每天定时运行或判断的生成图片,生成后在PHP写,如果有这个文件并且没过24小时则显示,过了,重新生成。
      

  3.   

    定时生成文件,将文件名保存到数据库或者xml文件里,每次页面从数据库或者xml文件里读取文件名.
     最好不要用相同的名字,因为缓存很麻烦.
      

  4.   

    就是个缓存嘛,用crontab以cli模式每天定时执行你的一个生成图片的php脚本,你的页面文件只需要加载那个文件就可以了。
      

  5.   

    我画图片的程序已经做好,不知道怎样保存到文件中。fwrite($fp,参数);那个参数怎么写?
      

  6.   

    imagepng($image,$imgname); png的格式图片质量高!