create a unique tracking code [duplicate]
Possible Duplicate:
how is create a unique tracking code
With this function i can create a unique tracking code?
What is your suggestion?<?php echo strtotime("now");?>
The number of characters not more than 10. Please call example powerful
What about the uniqid()
function ?
Gets a prefixed unique identifier based on the current time in microseconds.
With this functions, chances are far better for you to get a unique code than just using a data like you did in your question.
Also, you might want to take a look at what a GUID is.
It depends on the purpose of the your website...
In general, I would also add the user IP. so if two people are buying at the same time, you won't have an overlap.
If two users visit at exactly the same time, then they would have the same tracking code. I recommend using the Unix epoch as a seed for the mt_rand()
function.
//mt_srand(time()); Don't seed mt_rand
echo mt_rand();
You could also use it (or only a section of it, say the milliseconds) as a prefix or suffix to the random number. But that would pretty much emulate what uniquid()
does.
Apparently seeding is bad and boring (see @Gumbo). So don't do it.
精彩评论