Discussion on the use of PHP functions mt_srand

Source: Internet
Author: User

Description of the PHP function mt_srand

Void mt_srand (int seed)

Seed is used to seeding the random number generator. Starting from PHP 4.2.0, the seed parameter becomes optional. When this item is null, it is set to the number at any time.

Example 1. Example of the PHP function mt_srand

  1. <? Php
  2. // Seed with microseconds
  3. Function make_seed ()
  4. {
  5. List ($ usec, $ sec) = explode
    ('', Microtime ());
  6. Return (float) $ sec +
    (Float) $ usec * 100000 );
  7. }
  8. Mt_srand (make_seed ());
  9. $ Randval = mt_rand ();
  10. ?>

Note: As of PHP 4.2.0, the random number generator is no longer needed to be planted using srand () or the PHP function mt_srand, which is now automatically completed.
See mt_rand (), mt_getrandmax () and srand ().


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.