Share the unique order function generated by php, php order function _ PHP Tutorial

Source: Internet
Author: User
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...

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.