note 121557 deleted from function.mt-rand by cmb

From: Date: Sun, 19 Jan 2020 08:32:56 +0000
Subject: note 121557 deleted from function.mt-rand by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213906@lists.php.net to get a copy of this message
Note Submitter: abednico at mail dot com ---- Though you might all know this, by now: nonetheless, for 'slow- coaches', such as myself; Remember that mt_rand(), reacts DIFFERENTLY, Depending on your (initial) PHP script declaration. For People, such as myself, who have embraced strict-type; if your script is set to "declare(strict_types=1)", at the top of the page (just after opening PHP tag), remember one rule of thumb: If you pass a FLOAT into mt_rand WITHOUT strict-type set to 1, you should be good to go. However, if you HAVE set strict-types to 1, PHP WILL throw an exception:- "mt_rand() expects parameter 1 to be integer, float given". Just so that you don't have to spend a whole hour (like I did), trying to figure out why a script (with mt_rand()) that was working in a separate environment, isn't working now.

« previous php.notes (#213906) next »