CVS update: php3/doc/functions

From: Date: Sat, 24 Oct 1998 14:00:39 +0000
Subject: CVS update: php3/doc/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-1999@lists.php.net to get a copy of this message
Date: Saturday October 24, 1998 @ 10:00 Author: rasmus Update of /repository/php3/doc/functions In directory asf:/u2/tmp/cvs-serv17186/doc/functions Modified Files: math.sgml Log Message: rand() fixes and remove some bogus documentation Index: php3/doc/functions/math.sgml diff -c php3/doc/functions/math.sgml:1.14 php3/doc/functions/math.sgml:1.15 *** php3/doc/functions/math.sgml:1.14 Tue Oct 20 03:19:11 1998 --- php3/doc/functions/math.sgml Sat Oct 24 10:00:35 1998 *************** *** 578,621 **** <title>Description</title> <funcsynopsis> <funcdef>int <function>rand</function></funcdef> ! <paramdef>void </paramdef> </funcsynopsis> <simpara> ! Returns a pseudo-random value between 0 and RAND_MAX. If you want a ! random number between 5 and 15, for example, use rand()%10 + 5. <simpara> Remember to seed the random number generator before use with <function>srand</function>. - - <para> - Here are two handy functions that use <function>rand</function>. One returns a random integer less - than a specified maximum value, the other does the same but returns a real value. - <example><title>rand example functions</title> - <programlisting> - function randomint($max = 100) { - static $startseed = 0; - if (!$startseed) { - $startseed = (double)microtime()*getrandmax(); - srand($startseed); - } - return (rand()%$max); - } - - function random($max = 1) { - static $startseed = 0; - if (!$startseed) { - $startseed = (double)microtime()*getrandmax(); - srand($startseed); - } - return ((rand()/getrandmax())*$max); - } - </programlisting></example> - </para> - <simpara> - See also <function>srand</function> and - <function>getrandmax</function>. </refsect1> </refentry> --- 578,594 ---- <title>Description</title> <funcsynopsis> <funcdef>int <function>rand</function></funcdef> ! <paramdef><optional>int min</optional></paramdef> ! <paramdef><optional>int max</optional></paramdef> </funcsynopsis> <simpara> ! If called without the optional min,max arguments rand() returns a pseudo-random value between 0 and RAND_MAX. ! If you want a random number between 5 and 15 (inclusive), for example, use rand(5,15). <simpara> Remember to seed the random number generator before use with <function>srand</function>. </refsect1> </refentry> -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1999) next »