note 40969 rejected from function.rand by cece
| From: | cece@php.net | Date: | Thu, 25 Mar 2004 10:39:20 +0000 |
| Subject: | note 40969 rejected from function.rand by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-67147@lists.php.net to get a copy of this message | ||
Note Submitter: nes@students.uwf.edu
----
I was trying to pass a value I read from a text file into the rand function.
$how_many = fgets($file);
$n = rand(0, $how_many);
Would return: rand() expects parameter 2 to be long, string given
I was thrown because unless I missed it, I can't find anything about a variable type
'long' in the manual, ended up having to type it as (int)
$how_many = (int)fgets($file);
The value it was reading from the file was a line only containing
22980
Maybe the error message should say: int expected not long?