Funzione PHP uniqid()
Esempio
Genera un ID univoco:
<?php
echo uniqid();
?>
Definizione e utilizzo
La funzione uniqid() genera un ID univoco basato sul microtempo (l'ora corrente in microsecondi).
Nota: l'ID generato da questa funzione non garantisce l'unicità del valore restituito! Per generare un ID estremamente difficile da prevedere, utilizzare la funzione md5() .
Sintassi
uniqid(prefix,more_entropy)
Valori dei parametri
Parameter | Description |
---|---|
prefix | Optional. Specifies a prefix to the unique ID (useful if two scripts generate ids at exactly the same microsecond) |
more_entropy | Optional. Specifies more entropy at the end of the return value. This will make the result more unique. When set to TRUE, the return string will be 23 characters. Default is FALSE, and the return string will be 13 characters long |
Dettagli tecnici
Valore di ritorno: | Restituisce l'identificatore univoco, come stringa |
---|---|
Versione PHP: | 4+ |
Registro delle modifiche: | Il parametro prefix è diventato opzionale in PHP 5.0. Il limite di 114 caratteri per il prefisso è stato aumentato in PHP 4.3.1. |
❮ Riferimento a varie PHP