When PHP creates a verification code, what is the role of a parameter? For ($ I = 0; $ I & lt; $ num; $ I ++) {& nbsp; $ x = rand (1, 8) + $ imagewidth * $ I/4; $ y = rand (1, $ imageheight/4); $ font & nbsp; = & nbsp; ImageColorAllocate ($ im, When PHP creates a verification code, what is the role of a parameter?
For ($ I = 0; $ I <$ num; $ I ++ ){
$ X = rand (1, 8) + $ imagewidth * $ I/4;
$ Y = rand (1, $ imageheight/4 );
$ Font = ImageColorAllocate ($ im, rand (100,255), rand (0,100), rand (100,255); // Generate a random color
$ Authnum = rand (1, 9 );
$ Vcodes. = $ authnum;
Imagestring ($ im, 15, $ x, $ y, $ authnum, $ font );
}
In this loop statement, what is the function of $ num?
This is because the imagestring () function adds numbers to the image. I think $ num is definitely used to limit the number of numbers added to the image,
However, if you change $ num = 4, $ num = 15, or another number, the image is still 4 characters long.
I also want to ask, if it is weak, the parameters passed through post and get, such as login? Id = 2 & value = 3, this id, value through
After $ _ POST or $ _ GET is obtained, the values of id and value are integers or characters!
I don't want to verify it. it's too much trouble. thank you !!! PHP verification code $ _ POST:
------ Solution --------------------
The first question: do you want to use $ num = 2 to try it or use four numbers?
The calculation method of $ x can only display four numbers.
The second question is not clear whether it is a character or an integer, but it can be used as a character or an integer. this is the charm of PHP.
------ Solution --------------------
First, see upstairs.
Second string
------ Solution --------------------
You have fixed the image width and height...
------ Solution --------------------
$ X = rand (1, 8) + $ imagewidth * $ I/4;
Adjust the writing order.
$ X = $ imagewidth/4 * $ I + rand (1, 8 );
Where:
$ Imagewidth/4 Divide the canvas width into 4 points
$ Imagewidth/4 * $ I starting position of the $ I character on the canvas
Rand () let the starting position be shifted to several points
When the number of characters exceeds 4, there is no limit, but the calculated position is outside the canvas. Painted and White
------ Solution --------------------
Reference:
Quote: reference:
$ X = rand (1, 8) + $ imagewidth * $ I/4;
Adjust the writing order.
$ X = $ imagewidth/4 * $ I + rand (1, 8 );
Where:
$ Imagewidth/4 Divide the canvas width into 4 points
$ Imagewidth/4 * $ I starting position of the $ I character on the canvas
Rand () let the starting position be shifted to several points
When the number of characters exceeds 4, there is no limit, but the calculated position is outside the canvas. Painted and White
I seem to have understood it a bit. if I want to make the generated random code contain letters and numbers, how should I rewrite it?
Hope you can give me some advice