亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP development verification code tutorial to implement digital verification code

Implementing digital verification code

<?php
$image = imagecreatetruecolor(100,30);
$bgcolor = imagecolorallocate($image,255,255,255);//#FFFFFFFFFFFF
imagefill($image,0,0,$bgcolor);
for ($i=0;$i<4;$i++){
    $fontsize = 6;
    $fontcolor = imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120));
    $fontcontent = rand(0,9);
    $x = ($i * 100/4)+rand(5,10);
    $y = rand(5,10);
    imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor);
}
header('content-type: image/png');
imagepng($image);
//銷(xiāo)毀
imagedestroy($image);
?>

for ($i=0;$i<4;$i++){
//循環(huán)出四個(gè)數(shù)字
    $fontsize = 6;//字體的大小為6
    $fontcolor = imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120)); 
//定義字體的顏色
    $fontcontent = rand(0,9);//定義字體的取值范圍
}$x = ($i * 100/4)+rand(5,10);
$y = rand(5,10); 
在范圍內(nèi)隨機(jī)定義坐標(biāo)
imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor);
}

imagestring() uses col color to draw the string s to x of the image represented by image, y coordinate (this is the coordinate of the upper left corner of the string, the upper left corner of the entire image is 0, 0). If font is 1, 2, 3, 4 or 5, the built-in font is used.

Note: Control the size and distribution of fonts to avoid overlapping and incomplete display of fonts

Continuing Learning
||
<?php $image = imagecreatetruecolor(100,30); $bgcolor = imagecolorallocate($image,255,255,255);//#FFFFFFFFFFFF imagefill($image,0,0,$bgcolor); for ($i=0;$i<4;$i++){ $fontsize = 6; $fontcolor = imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120)); $fontcontent = rand(0,9); $x = ($i * 100/4)+rand(5,10); $y = rand(5,10); imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor); } header('content-type: image/png'); imagepng($image); //銷(xiāo)毀 imagedestroy($image); ?>
submitReset Code