-
-
Save thelebster/64d852499e29e4c70e3277c48cb3f375 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
Note, the newline is not part of the
uniqidfunction: