Order Number Problem Solving

Source: Internet
Author: User
Order Number problem solving? $ OrderYmdHis). mt_rand (); is this correct? Why is the gb_0000505 obtained in this way? How likely will this order number be to be the same? ------ Solution -------------------- random number, of course, the probability is the same, but there may be repeated ---- Order number problem solving?
$ Orderid = GB _. substr (date ('ymdhis '). mt_rand );

Is that true?

Why is the gb_0000505 obtained in this way? How likely will this order number be to be the same?

------ Solution --------------------
Of course, the probability of a random number is the same, but there is a possibility of repetition.
------ Solution --------------------
GB _. substr (date ('ymdhis '). mt_rand );

Substr ($ string, $ start, $ length );

This method requires three parameters: the first is the string, that is, your time, the second is the starting position of the truncation, and the third is the truncation length.
------ Solution --------------------
$ Orderid = 'GB _ '. date ('ymdhis'). mt_rand );

Although it is unlikely that a random number will conflict with each other (one thousandth of you)
But he is not continuous and is not easy to manage. It cannot prevent forgery.

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.