php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #44904 mt_rand does not accept a single parameter but documented like it does
Submitted: 2008-05-03 15:31 UTC Modified: 2008-05-03 16:48 UTC
From: twk at nonn-et-twk dot net Assigned: bjori (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Windows
Private report: No CVE-ID: None
 [2008-05-03 15:31 UTC] twk at nonn-et-twk dot net
Description:
------------
In mt_rand documentation, 
http://docs.php.net/manual/en/function.mt-rand.php
http://php.net/manual/en/function.mt-rand.php
It seems the function accepts one or two parameters.
int mt_rand ([ int $min ], int $max )

However, it does not accept a single parameter, 
but no or two parameters.

mt_rand($max); // genreates a warning.
Warning: mt_rand() expects exactly 2 parameters, 1 given 
mt_rand() or mt_rand($min, $max) are ok.

The documented prototype should be same as rand()'s.
http://php.net/manual/en/function.rand.php
int rand ( void )
int rand ( int $min , int $max )

See also http://bugs.php.net/bug.php?id=12550





Reproduce code:
---------------
See http://docs.php.net/manual/en/function.mt-rand.php



Expected result:
----------------
int mt_rand ( void )
int mt_rand ( int $min , int $max )
(like http://php.net/manual/en/function.rand.php)

or

int mt_rand ([ int $min , int $max ])





Actual result:
--------------
int mt_rand ([ int $min ], int $max )





Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-03 16:09 UTC] colder@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Same issue as #44855
 [2008-05-03 16:10 UTC] colder@php.net
My bad, #44885
 [2008-05-03 16:48 UTC] bjori@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 23:00:01 2026 UTC