note 40969 added to function.rand

From: Date: Thu, 25 Mar 2004 00:48:45 +0000
Subject: note 40969 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-67131@lists.php.net to get a copy of this message
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? ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40969 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40969&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40969&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67131) next »