How random is PHP's shuffle function?

后端 未结 7 1980
眼角桃花
眼角桃花 2020-12-03 21:12

Does anyone know what\'s the randomness of PHP\'s shuffle() function? Does it depend on the operating system? Does it use PHP\'s own seeder?

Is it poss

7条回答
  •  孤城傲影
    2020-12-03 21:33

    Update for PHP 7.1

    Since the rng_fixes rfc was implemented for PHP 7.1, the implementation of shuffle now utilizes the Mersenne Twister PRNG (i.e. it uses mt_rand and is affected by calling mt_srand).

    The legacy system PRNG (rand) is no longer available; the functions rand and srand are in fact aliased to their mt_ equivalents.

提交回复
热议问题