Skip to content

Instantly share code, notes, and snippets.

@kelunik
Created February 2, 2017 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kelunik/bb534d4c4ede160d97ef17014052052a to your computer and use it in GitHub Desktop.
Save kelunik/bb534d4c4ede160d97ef17014052052a to your computer and use it in GitHub Desktop.
--- en/reference/math/functions/mt-rand.xml
+++ en/reference/math/functions/mt-rand.xml
@@ -3,7 +3,7 @@
<refentry xml:id="function.mt-rand" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>mt_rand</refname>
- <refpurpose>Generate a better random value</refpurpose>
+ <refpurpose>Generate a predictable random value</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
@@ -16,15 +16,18 @@
<methodparam><type>int</type><parameter>min</parameter></methodparam>
<methodparam><type>int</type><parameter>max</parameter></methodparam>
</methodsynopsis>
+ &caution.cryptographically-insecure;
<simpara>
- Many random number generators of older libcs have dubious or
- unknown characteristics and are slow. By default, PHP uses the
+ The <function>mt_rand</function> function is a drop-in replacement
+ for the older <function>rand</function>. It uses a random
+ number generator with known characteristics using the
+ <link xlink:href="&url.mersenne;">Mersenne Twister</link>, which
+ will produce random numbers four times faster than what the average
+ libc rand() provides. Many random number generators of older libcs
+ have dubious or unknown characteristics and are slow. PHP used the
libc random number generator with the <function>rand</function>
- function. The <function>mt_rand</function> function is a drop-in
- replacement for this. It uses a random number generator with
- known characteristics using the <link xlink:href="&url.mersenne;">
- Mersenne Twister</link>, which will produce random numbers four times
- faster than what the average libc rand() provides.
+ function, but as of PHP 7.1 <function>rand</function> is now an
+ alias for <function>mt_rand</function>.
</simpara>
<simpara>
If called without the optional <parameter>min</parameter>,
@@ -34,7 +37,6 @@
between 5 and 15 (inclusive), for example, use <literal>mt_rand(5,
15)</literal>.
</simpara>
- &caution.cryptographically-insecure;
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment