PHP get random numbers and letters method Daquan _php Tutorial

Source: Internet
Author: User
The first of these methods The second method of The third method of Isn't this the same as the one below? are random output 10-100 between the number of new students learning, may ask too simple OH Mt_rand (10,100); Srand is a seed, and if it's not, the default is 1 rand is generally a fixed operation that uses seed to make parameters. You know, without seeding or setting a fixed seed, running Rand and then closing the browser and then running Rand you'll find the results are always the same first say Rand () function bar, rand ([int min], [int max]) This function takes a random number between Min and Max. Without specifying the maximum and minimum range of random numbers, this function automatically takes a random number from 0 to Rand_max. However, if only rand () is used, the random number is very chaotic and it is best to use the Srand () function to configure a new random number seed each time before taking a random number. Explain the following usage (which is generally the case with these two functions): Srand (Double) microtime () *1000000); $rand _number= rand (); Microtime () returns two values: the current millisecond and timestamp, we want to extract the random number, only a random number from the millisecond, (double) microtime () only returns the current millisecond value. Microtime () is the number of milliseconds in seconds, and the value is a decimal, multiplied by 1000000 to convert it to integers. The workflow is as follows: (1): First, give Srand () a "seed", which is a value of type Unsigned_int. (2): _ Then, call Rand (), which returns a random number (in the range between _0~32767) based on the value provided to Srand () (3): Call rand () as many times as necessary to keep getting new random numbers. (4): Whenever you can provide Srand () with a new "seed", further "Randomize" rand () output results.

http://www.bkjia.com/PHPjc/477855.html www.bkjia.com true http://www.bkjia.com/PHPjc/477855.html techarticle The first method? PHP $FileID =date (ymd-his). rand (100,999);//$FileID a random number such as 20100903-132121-908? The second method? PHP function ran Domkeys ($length) {$returnS ...

  • 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.