|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78093 mt_rand returns NULL in some cases
Submitted: 2019-05-31 14:47 UTC Modified: 2019-05-31 14:51 UTC
From: sidorovmarat1995 at gmail dot com Assigned:
Status: Not a bug Package: Math related
PHP Version: 7.2.19 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: sidorovmarat1995 at gmail dot com
New email:
PHP Version: OS:


 [2019-05-31 14:47 UTC] sidorovmarat1995 at gmail dot com
In mt_rand docs I can't find possibility of returning NULL.
I suggest return false in this situation(see test script).

Test script:

Expected result:

Actual result:


mt-rand (last revision 2019-05-31 14:48 UTC by sidorovmarat1995 at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-31 14:48 UTC] sidorovmarat1995 at gmail dot com
The following patch has been added/updated:

Patch Name: mt-rand
Revision:   1559314100
 [2019-05-31 14:50 UTC] sidorovmarat1995 at gmail dot com
Sorry, I don't know how to fix this issue.
And you can see my path is only random txt file from my PC.
 [2019-05-31 14:51 UTC]
-Status: Open +Status: Not a bug
 [2019-05-31 14:51 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at See the warnings?
> Note: If the parameters given to a function are not what it expects, such as passing an array where a string is
> expected, the return value of the function is undefined. In this case it will likely return NULL but this is just
> a convention, and cannot be relied upon.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Mar 02 04:01:28 2024 UTC