Php generates a unique order function sharing, and php order function. The only order function generated by php is shared. more and more e-commerce and e-commerce systems use php order functions to generate order numbers, I believe that the order number problem is the only order function share generated by php, and the php order function.
Solution for generating order numbers
E-commerce and e-commerce systems are growing. I believe that the order number problem is the most common problem in such systems, but I still want to talk about it today.
In the past few days, I have taken over a transaction system developed by another colleague, which was originally generated by the uniqid () function. Theoretically, there will be no duplicates, but for some special reasons, we have to re-create a function for generating order numbers.
The code is as follows:
/**
* Generate a unique order number 20110809111259232312
* 2011-date of the year
* 08-month
* 09-date
* 11-hour
* 12-minute
* 59-seconds
* 2323-microseconds
* 12-random value
* @ Return string
*/
Public function trade_no (){
List ($ usec, $ sec) = explode ("", microtime ());
$ Usec = substr (str_replace ('0. ', '', $ usec), 0, 4 );
$ Str = rand (10, 99 );
Return date ("YmdHis"). $ usec. $ str;
}
The above is all the content of this article. I hope you will like it.
There are more and more e-commerce and e-commerce systems on the solution for generating order numbers. I believe the problem with order numbers is that such systems...