Skip to content

[13.x] Use modern alternative for random functions#60016

Closed
lucasmichot wants to merge 1 commit into
laravel:13.xfrom
lucasmichot:13.x-random
Closed

[13.x] Use modern alternative for random functions#60016
lucasmichot wants to merge 1 commit into
laravel:13.xfrom
lucasmichot:13.x-random

Conversation

@lucasmichot
Copy link
Copy Markdown
Contributor

Use modern alternative for random functions

@browner12
Copy link
Copy Markdown
Contributor

My understanding is random_int is only required for cryptographically secure random number generation.

While they both do work for random number generations, random_int can be less performant than mt _rand/rand. Even in my very basic 3v4l script below, mt_rand is about twice as fast as random_int.

Links for the lazy:

https://www.php.net/manual/en/function.random-int.php

https://www.php.net/manual/en/function.mt-rand.php

https://www.php.net/manual/en/migration71.incompatible.php#migration71.incompatible.rand-srand-aliases

https://3v4l.org/fPuMg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants