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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Wed Jun 26 16:01:30 2024 UTC