Interference elements (line) in PHP development verification code tutorial

In the previous section, we have used to add interference elements (dots)

Next we will add interference elements (lines)

In the above code, we have added interference elements dots

Let’s take a look at adding interference elements, line

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

//First we set the line in the loop The number of lines is 5

//Set the color of the line, the color of the text is between 1 and 120, then the color of our line is lighter than the color of the text, set 80, 220

$linecolor = imagecolorallocate($image,rand(80,220),rand(80,220),rand(80,220));

//Then set the position of the line

imageline($image,rand(1,99),rand(1,29),rand(1,99),rand(1,29),$linecolor);

}

Let’s take a look at the complete code:

With the above code, we have created a simple verification code

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