MyBB Community Forums

Full Version: rand() -> mt_rand() in few places
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Not sure why you use function rand() in few places:
init.php
functions.php
captcha.php

From PHP manual:
Quote:Many random number generators of older libcs have dubious or unknown characteristics and are slow. By default, PHP uses the libc random number generator with the rand() function. The mt_rand() function is a drop-in replacement for this. It uses a random number generator with known characteristics using the ยป Mersenne Twister, which will produce random numbers four times faster than what the average libc rand() provides.


In file init.php:
FIND:
PHP Code:
// Generate a random number for performing random actions.
$rand rand(010); 
REPLACE WITH:
PHP Code:
// Generate a random number for performing random actions.
$rand mt_rand(010); 

In file functions.php:
FIND:
PHP Code:
$ch rand(0count($set)-1); 
REPLACE WITH:
PHP Code:
$ch mt_rand(0count($set)-1); 

In captcha.php - many lines.

MyBB: 1.2.3
Because we don't like to be twisted.

Haha bad joke. It's a valid point.
Used it on my global.php and some other stuff that I wrote myself.

Would have to say that this one is really increasing my sites performance.
nameslot Wrote:Would have to say that this one is really increasing my sites performance.
LOL!

That was a joke, right?
Reference URL's