homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Something puzzling me in PHP
rand() function

 7:54 pm on Mar 26, 2001 (gmt 0)

A while ago I pinched a snippet of PHP from somewhere to use in a session id generator. It all worked fine, but as I was only just starting out in PHP I didn't investigate too deeply how it worked. This construct is now puzzling me:


The effect is to choose a random number between zero and the character length of string $pool - yet I can't find any documentation on this form of rand() anywhere... the manual for PHP4 specifies rand(min_value, max_value) for this kind of thing.

Does anyone know if this is a correct construct or a hangover from an earlier version of PHP?



 2:11 am on Mar 28, 2001 (gmt 0)

It's not a hangover. If no seed value is provided, the rand() function is automatically seeded with a value of 1.


 10:23 am on Mar 29, 2001 (gmt 0)

Thanks Froggyman. It's the % sign that puzzles me - I take it this is just a different method of specifying the maximum value?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved