uniqid

string uniqid(string prefix) 

Generates a unique ID.

Returns:

Unique value

Description:

This handy function creates a unique identifier based on the current number of microseconds. An optional prefix of up to 114 characters can be used to differentiate between several types of IDs or to provide another level of abstraction. This prefix is prepended to the generated ID. Since this function is based on the microtime, the variety of the generated IDs is not optimal; when the system time is known, a small amount of predictability comes into place. To generate hard-to-reproduce IDs, see the md5() function.

Example:

Generate a unique ID
 <?php // See the random number generator srand ((double) microtime () * 1000000); // Generate a 12-character ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.