Skip to content

Instantly share code, notes, and snippets.

@shahid249
Created June 25, 2017 07:08
Show Gist options
  • Save shahid249/7166828c66c8e5779015499cd67b1ce8 to your computer and use it in GitHub Desktop.
Save shahid249/7166828c66c8e5779015499cd67b1ce8 to your computer and use it in GitHub Desktop.
Random Unique ID Generator in PHP
<?php
// with prefix
$uniqueid = uniqid('prefixhere_');
echo $uniqueid;
/* prints
prefixhere_594f60936a7e9
*/
// with more entropy
$uniqueid_2 = uniqid('',true);
echo $uniqueid_2;
/* prints
594f60b9819a19.45879433
*/
// prefix + entropy
$uniqueid_3 = uniqid('prefixand_',true);
echo $uniqueid_3;
/* prints
prefixand_594f60d83cda14.54121719
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment