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

Ajout de contenu au didacticiel du code de vérification du développement PHP

Dans la section précédente, nous avons déjà créé un canevas

Ensuite, nous changeons la couleur attribuée en blanc, le code est le suivant?:

<?php
    //第一步 創(chuàng)建一個(gè)畫(huà)布
    $image = imagecreatetruecolor(100, 30); //創(chuàng)建一個(gè)寬為100高為30的黑色圖像
    $bgcolor = imagecolorallocate($image, 255, 255, 255); //為圖像分配顏色
    imagefill($image,0,0,$bgcolor); //給黑色的背景圖像分配白色

    //輸出圖像
    header("content-type:image/png");
    imagepng($image);

    //銷(xiāo)毀資源
    imagedestroy($img);

?>

Ensuite, nous devons ajouter content Par exemple, si vous ajoutez 4 nombres aléatoires

, alors nous devons utiliser une boucle pour opérer

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

??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ?ImageColoraLocate 0,9); > $x = ($ i*100/4)+rand(5,10);

$y = rand(5,10);

imagestring($image,$fontsize,$x, $y,$fontcontent, $fontcolor);


}

De cette fa?on, nous remplissons le canevas avec les chiffres 0-9. Le code complet est le suivant?:

<?php
    //第一步 創(chuàng)建一個(gè)畫(huà)布
    $image = imagecreatetruecolor(100, 30); //創(chuàng)建一個(gè)寬為100高為30的黑色圖像
    $bgcolor = imagecolorallocate($image, 255, 255, 255); //為圖像分配顏色
    imagefill($image,0,0,$bgcolor); //給黑色的背景圖像分配白色
    

    //第二步,在這個(gè)圖像上實(shí)現(xiàn)數(shù)字
    for($i=0;$i<4;$i++){
        $fontsize = 6; //字體大小

        $fontcolor = imagecolorallocate($image,rand(1,120),rand(1,120),rand(1,120));
        //設(shè)置字體的顏色  顏色我們給一個(gè)隨機(jī)的值,畫(huà)布為白色,0到120之間,顏色為深色
        $fontcontent = rand(0,9); //設(shè)置內(nèi)容是一個(gè)隨機(jī)數(shù)

        //現(xiàn)在需要把這個(gè)隨機(jī)數(shù)添加到畫(huà)布上去
        $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($img);

?>

Formation continue
||
<?php //第一步 創(chuàng)建一個(gè)畫(huà)布 $image = imagecreatetruecolor(100, 30); //創(chuàng)建一個(gè)寬為100高為30的黑色圖像 $bgcolor = imagecolorallocate($image, 255, 255, 255); //為圖像分配顏色 imagefill($image,0,0,$bgcolor); //給黑色的背景圖像分配白色 //第二步,在這個(gè)圖像上實(shí)現(xiàn)數(shù)字 for($i=0;$i<4;$i++){ $fontsize = 6; //字體大小 $fontcolor = imagecolorallocate($image,rand(1,120),rand(1,120),rand(1,120)); //設(shè)置字體的顏色 顏色我們給一個(gè)隨機(jī)的值,畫(huà)布為白色,0到120之間,顏色為深色 $fontcontent = rand(0,9); //設(shè)置內(nèi)容是一個(gè)隨機(jī)數(shù) //現(xiàn)在需要把這個(gè)隨機(jī)數(shù)添加到畫(huà)布上去 $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($img); ?>
soumettreRéinitialiser le code
  • Recommandations de cours
  • Téléchargement du didacticiel