Tutoriel de code de vérification de développement PHP pour implémenter le code de vérification numérique

Implémentation du code de vérification numérique

<?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);
//销毁
imagedestroy($image);
?>

for ($i=0;$i<4;$i++){
//循环出四个数字
    $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); 
在范围内随机定义坐标
imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor);
}

imagestring() utilise la couleur col pour dessiner la chaîne s à x de l'image représentée par image, Coordonnée y (c'est la coordonnée du coin supérieur gauche de la chaîne, le coin supérieur gauche de l'image entière est 0, 0). Si la police est 1, 2, 3, 4 ou 5, la police intégrée est utilisée.

Remarque : Contrôlez la taille et la répartition des polices pour éviter les chevauchements et l'affichage incomplet des polices

Formation continue
||
<?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); //销毁 imagedestroy($image); ?>
soumettreRéinitialiser le code
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!