uniqid

(PHP 4, PHP 5, PHP 7)

uniqid锟斤拷锟斤拷一锟斤拷唯一ID

说锟斤拷

uniqid ([ string $prefix = "" [, bool $more_entropy = false ]] ) : string

锟斤拷取一锟斤拷锟斤拷前缀锟斤拷锟斤拷锟节碉拷前时锟斤拷微锟斤拷锟斤拷锟斤拷唯一ID锟斤拷

Caution

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟缴帮拷全锟斤拷锟杰碉拷值锟斤拷锟斤拷应锟斤拷锟节硷拷锟斤拷锟斤拷途锟斤拷锟斤拷锟斤拷要锟斤拷全锟斤拷锟杰碉拷值锟斤拷锟斤拷锟斤拷使锟斤拷openssl_random_pseudo_bytes()锟斤拷

Warning

锟剿猴拷锟斤拷锟斤拷锟斤拷证锟斤拷锟斤拷值锟斤拷唯一锟皆★拷 锟斤拷锟节撅拷锟斤拷锟斤拷锟较低呈癸拷锟� NTP 锟斤拷锟斤拷锟斤拷锟狡凤拷锟斤拷锟斤拷锟较低筹拷锟绞憋拷洌拷锟斤拷锟较低呈憋拷渚拷锟斤拷锟斤拷锟斤拷浠拷锟� 锟斤拷锟解,锟斤拷锟斤拷/锟竭程匡拷锟杰诧拷锟结返锟斤拷唯一锟斤拷 ID锟斤拷 锟斤拷 more_entropy 锟斤拷锟斤拷锟斤拷唯一锟皆的革拷锟绞★拷

锟斤拷锟斤拷

prefix

锟斤拷锟矫的诧拷锟斤拷锟斤拷锟斤拷锟界:锟斤拷锟斤拷诙锟教拷锟斤拷锟斤拷峡锟斤拷锟斤拷锟酵晃拷锟斤拷锟斤拷锟轿ㄒ籌D锟斤拷

prefix为锟秸o拷锟津返回碉拷锟街凤拷锟斤拷锟斤拷锟斤拷为13锟斤拷more_entropyTRUE锟斤拷锟津返回碉拷锟街凤拷锟斤拷锟斤拷锟斤拷为23锟斤拷

more_entropy

锟斤拷锟斤拷锟斤拷锟轿� TRUE锟斤拷uniqid() 锟斤拷锟节凤拷锟截碉拷锟街凤拷锟斤拷锟斤拷尾锟斤拷锟接讹拷锟斤拷锟斤拷兀锟绞癸拷锟絚ombined linear congruential generator锟斤拷锟斤拷 使锟斤拷唯一ID锟斤拷锟斤拷唯一锟皆★拷

锟斤拷锟斤拷值

锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷式锟斤拷唯一ID锟斤拷

Warning

锟剿猴拷锟斤拷努锟斤拷锟斤拷锟斤拷唯一识锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟街わ拷锟斤拷锟街碉拷锟轿ㄒ伙拷浴锟�

锟斤拷锟斤拷

Example #1 uniqid() 锟斤拷锟斤拷

<?php
/* A uniqid, like: 4b3403665fea6 */
printf("uniqid(): %s\r\n"uniqid());

/* We can also prefix the uniqid, this the same as 
 * doing:
 *
 * $uniqid = $prefix . uniqid();
 * $uniqid = uniqid($prefix);
 */
printf("uniqid('php_'): %s\r\n"uniqid('php_'));

/* We can also activate the more_entropy parameter, which is 
 * required on some systems, like Cygwin. This makes uniqid()
 * produce a value like: 4b340550242239.64159797
 */
printf("uniqid('', true): %s\r\n"uniqid(''true));
?>

注锟斤拷

Note:

锟斤拷Cygwin锟斤拷锟斤拷锟铰o拷为锟斤拷使锟剿猴拷锟斤拷锟杰癸拷锟斤拷锟斤拷锟斤拷more_entropy 锟斤拷锟斤拷锟斤拷锟斤拷为 TRUE锟斤拷