显示页面代码

<!DOCTYPEhtml><html><head><title>time</title></head><body><imgid="time"src="index.php"/><script>setInterval(function(){document.getElementById('time').src="index.php?"+Math.random();},1000);</script></body></html>

画图页面代码

/**绘制时钟*///获取系统时间date_default_timezone_set('PRC');$h=date('H');$i=date('i');$s=date('s');//1.创建资源画布的大小$img=p_w_picpathcreatetruecolor(200,250);$white=p_w_picpathcolorallocate($img,0xFF,0xFF,0xFF);$red=p_w_picpathcolorallocate($img,255,0,0);$blue=p_w_picpathcolorallocate($img,0,0,0xFF);$pink=p_w_picpathcolorallocate($img,0xFF,0,0xFF);p_w_picpathfill($img,0,0,$white);//画椭圆p_w_picpathellipse($img,100,100,190,190,$blue);p_w_picpathfilledellipse($img,100,100,4,4,$blue);p_w_picpathstring($img,4,95,8,'12',$pink);p_w_picpathstring($img,4,175,95,'03',$pink);p_w_picpathstring($img,4,95,175,'06',$pink);p_w_picpathstring($img,4,11,95,'09',$pink);//秒针$len=80;$a=$len*sin(pi()/30*$s);//注意是秒针与竖线形成的夹角每秒走过6度sin()里面是按弧度作为参数要将度换算成弧度$b=$len*cos(pi()/30*$s);$x=100+$a;//秒针线末端x轴的坐标$y=100-$b;//秒针线末端y轴的坐标//分钟$len1=1;$a1=$len*sin(pi()/1800*$s);$b1=$len*cos(pi()/1800*$s);$x1=100+$a1;//秒针线末端x轴的坐标$y1=100-$b1;//秒针线末端y轴的坐标//秒针p_w_picpathline($img,100,100,$x,$y,$red);//指针p_w_picpathline($img,100,100,$x1,$y1,$blue);//数字的时间p_w_picpathstring($img,5,20,230,"now:{$h}:{$i}:{$s}",$red);//4.保存或输出给浏览器写第二个参数就是保存header('Content-type:p_w_picpath/jpeg');p_w_picpathpng($img);//5.释放资源p_w_picpathdestroy($img);

结果为