Last active
May 6, 2017 10:23
-
-
Save james2doyle/d850c7ef32171131303113a205e56796 to your computer and use it in GitHub Desktop.
PHP uniqid function written in pure PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * Use this if you need to recreate `uniqid` in another language | |
| * From: http://php.net/manual/en/function.uniqid.php#95001 | |
| */ | |
| // time in microseconds as float | |
| $m = microtime(true); | |
| // show me the results | |
| echo sprintf("%8x%05x\n", floor($m), ($m - floor($m)) * 1000000); | |
| // show me the real call to `uniqid` | |
| echo uniqid(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment