The code does not understand the solution

Source: Internet
Author: User
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'
';}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.