PHP function to generate v4 UUID

前端 未结 15 1093
眼角桃花
眼角桃花 2020-11-22 03:01

So I\'ve been doing some digging around and I\'ve been trying to piece together a function that generates a valid v4 UUID in PHP. This is the closest I\'ve been able to come

15条回答
  •  故里飘歌
    2020-11-22 03:41

    Use Symfony Polyfill / Uuid
    Then you can just generate uuid as native php function:

    $uuid = uuid_create(UUID_TYPE_RANDOM);
    

    More about it, read in official Symfony blop post - https://symfony.com/blog/introducing-the-new-symfony-uuid-polyfill

提交回复
热议问题