Why not to use rand() in PHP

The rand() function in PHP is much more older, and doesn't generate such a good results as mt_rand(). What means good ? Just random. Computers cannot create real random numbers, so rand() and mt_rand() are just using some mathematic calculations to create pseudo random numbers, and mt_rand() has better and faster algorithm. Code sample:$i = rand(1,5); // don't use ! $i = mt_rand(1,5); // betterIf you want to check this, just generate a image with black and white pixels, selecting it by rand and mt_rand 0 and 1 values. You can see some patter-like areas in image created by rand()

Comments

Popular posts from this blog

How to show only month and year fields in android Date-picker?

How to construct a B+ tree with example

Conflict Serializability in database