php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16764 srand(microtime()) generates warning
Submitted: 2002-04-23 15:11 UTC Modified: 2002-04-23 15:16 UTC
From: heyjohnlim at yahoo dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.2.0 OS: Win2000, IIS-CGI
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: heyjohnlim at yahoo dot com
New email:
PHP Version: OS:

 

 [2002-04-23 15:11 UTC] heyjohnlim at yahoo dot com
Is this a bug, or is microtime implementing stricter type checking? After all most faq's list this as the recommended way of generating a seed. 

<?php
srand(microtime());
?>

Generates:

Warning: srand() expects parameter 1 to be long, string given in d:\inetpub\wwwroot\php\test.php on line 2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-23 15:16 UTC] derick@php.net
INdeed was stricter type chcking implemented.
This should work:

srand ((int) microtime());

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Sep 28 23:01:27 2024 UTC