session报错
富贵
富贵 2017-09-29 21:48:29
0
3
1514

<?php

session_start();

$str = '';

$width = 300;

$height = 100 ;

$img = imagecreatetruecolor($width,$height);

$white = imagecolorallocate($img, 255, 255, 255);

$red = imagecolorallocate ($img, 255, 0, 0);

imagefilledrectangle($img, 0, 0, $width, $height, setColor($img));

function setColor($img )

{

return imagecolorallocate($img,getColor(),getColor(),getColor());

}

function getColor()

{

return mt_rand(0,255);

}

function setNum($a,$b)

{

return mt_rand($a,$b);

}

function getCode()

{

return $string = join( '',array_rand(array_flip(array_merge(范围(0,9),范围('a','z'),范围('A','Z')),4));

}

$str = getCode();

for($i=0;$i<4;$i++)

{

$size = setNum(20,50);

$angle = setNum(-15,15);

$x = ($width/4)*$i+ mt_rand(1,9);

$y = mt_rand(($height/2),$height);

$color = setColor( $img );

$fontfile = './fonts/MSYH.ttf';

$text = mb_substr($str,$i,1,'utf-8');

imagettftext($img, $size, $angle, $x, $y, $color, $fontfile, $text);

}

for($i=0;$i<1500;$i++)

{

imagesetpixel($img, mt_rand(0, $width), mt_rand(0, $height), setColor($img));

}

for($i=0;$i<3;$i++)

{

imageline($img, mt_rand(0, $width), mt_rand(0,$height), mt_rand(0, $width), mt_rand(0,$height), setColor($图像));

}

for($i=0;$i<3;$i++)

{

$cx = mt_rand(0, $width );

$cy = mt_rand(0, $height);

$width = mt_rand(0, $width/2);

$height = mt_rand(0, $高度/2);

$start = mt_rand(0, 360);

$end = mt_rand(0, 360);

$color = setColor($img );

imagearc($img, $cx, $cy, $width, $height, $start, $end, $color);

}

$_SESSION['verifycode'] = $str;

header('content-type:image/jpeg');

imagejpeg ( $img );

imagedestroy( $img );

?>


富贵
富贵

全部回复(3)
寻觅 beyond

应该是你绘图的某个步骤出问题了,生成的四个随机字符成功了的

林

起码要吧报错的内容一起发出来啊  ,要不怎么知道你报的什么错啊

直奔十维

不知道什么原因不知道什么原因不知道什么原因不知道什么原因

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!