Added content to the PHP development verification code tutorial

In the previous section we have already created a canvas

Now we change the assigned color to white, the code is as follows:

Next we need to add content For example, if you add 4 random numbers

, then we have to use a loop to operate

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

imagecolorallocate($image,rand(1,120),rand(1,120),rand(1,120));

// The setting content is a random number from 0 to 9

$fontcontent = rand( 0,9);

through i*100/4)+rand(5,10);

$y = rand(5,10);

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


}

In this way, we fill the canvas with numbers 0-9. The complete code is as follows:


Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!