Home > Backend Development > PHP Tutorial > 灵异的for循环

灵异的for循环

WBOY
Release: 2016-06-13 13:39:40
Original
739 people have browsed it

灵异的for循环请高手看看
/*for($i=0;$i $rand .= dechex(rand(1,15));
}*/
 $img = imagecreatetruecolor(80,20);
 $bg = imagecolorallocate($img,0,0,0);
 $te = imagecolorallocate($img,255,255,255);
imagestring($img,5,rand(5,40),0,"aaa",$te); //第一个是字体然后 X Y

imageline($img,rand(1,80),rand(1,20),rand(1,80),rand(1,20),$te);

header("Content-type: image/jpeg");
imagejpeg($img);
?>

上面的for循环 本想是循环16进制的5位数
需要把他注掉的原因是 因为如果不注掉下面的图片显示不出来
奇怪我也没用$rand呀 为什么不行
我在imagestring里面我是随便写了一个字符串"aaa" 换成$rand 图片就成小×了。。。。

------解决方案--------------------
经测试,我机器上也存在这个问题
解决办法:header("Content-type: image/jpeg");上一行加上 ob_clean();

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template