PHP generates a random string of the specified number of bits (length)

Source: Internet
Author: User
  1. /**
  2. * Generate a string of the specified length
  3. * by bbs.it-home.org
  4. */
  5. function create_random_string ($random _length) {
  6. $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  7. $random _string = ";
  8. for ($i = 0; $i < $random _length; $i + +) {
  9. $random _string. = $chars [Mt_rand (0, strlen ($chars)-1)];
  10. }
  11. return $random _string;
  12. }
Copy Code

The simple point of writing, the value of the random string in the range of Random{0-9,a-z,a-z}.

>>> You may be interested in the article: PHP random string generation function PHP generates random string functions PHP generates random string of two examples PHP generates random string of two ways a simple PHP randomly generated string function is useful 3 PHP random string function generator PHP generated random number example PHP create a readable The code for the machine string uses PHP to generate a random string of code for PHP to generate random numbers and letter instance codes

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