Do not understand the code // randomly display the four numbers on the canvas. the horizontal spacing and position of the characters are randomly generated according to a certain fluctuation range & nbsp; $ im = imagecreate (60, 20) & nbsp; & nbsp; $ strx = rand (); & nbsp; for ($ I = 0; $ I & lt; 4; $ I ++) {& nbsp; $ the code does not understand
// Display the four numbers randomly on the canvas. the horizontal spacing and position of the characters are randomly generated according to a certain fluctuation range.
$ Im = imagecreate (60, 20)
$ Strx = rand (3, 8 );
For ($ I = 0; $ I <4; $ I ++ ){
$ Strpos = rand (1, 6 );
Imagestring ($ im, 5, $ strx, $ strpos, substr ($ num, $ I, 1), $ black );
$ Strx + = rand (8, 12 );
}
In the above code, $ strx = rand (); $ strx + = rand (); these two sentences are not quite clear. how can they divide $ im 60 equally, or is it not even a split here? can you help me explain the meaning of the two codes? In particular, $ strx + = rand (8, 12). thank you first.
------ Solution --------------------
$ Strx + = rand (8, 12); $ strx = $ strx + rand (8, 12 );
------ Solution --------------------
Elegant but not flexible
PHP code
$ Strx = 8; // rand () is between 3 and 8, and the maximum value is 8for ($ I = 0; $ I <4; $ I ++) {echo $ strx + = 12; // rand (8, 12) is between 8 and 12, and the maximum value is 12 echo'
';}