将以下代码拿到 http://www.dooccn.com/php/ 运行, 得到UUID

    1. <?php
    2. function gen_uuid()
    3. {
    4. return sprintf(
    5. '%04x%04x%04x%04x%04x%04x%04x%04x',
    6. // 32 bits for "time_low"
    7. mt_rand(0, 0xffff),
    8. mt_rand(0, 0xffff),
    9. // 16 bits for "time_mid"
    10. mt_rand(0, 0xffff),
    11. // 16 bits for "time_hi_and_version",
    12. // four most significant bits holds version number 4
    13. mt_rand(0, 0x0fff) | 0x4000,
    14. // 16 bits, 8 bits for "clk_seq_hi_res",
    15. // 8 bits for "clk_seq_low",
    16. // two most significant bits holds zero and one for variant DCE1.1
    17. mt_rand(0, 0x3fff) | 0x8000,
    18. // 48 bits for "node"
    19. mt_rand(0, 0xffff),
    20. mt_rand(0, 0xffff),
    21. mt_rand(0, 0xffff)
    22. );
    23. }
    24. for ($i = 0; $i < 100; $i++) {
    25. echo gen_uuid().PHP_EOL;
    26. }