Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

The sin function returns the sine of the angle. The angle is assumed to be in radians.


<?
//prints 1
print(sin(0.5 * M_PI));
?>


double sqrt(double value)


Use sqrt to find the square root of a number.


<?
//prints 9
print(sqrt(81.0));
?>


double tan(double angle)


The tan function returns the tangent of an angle. The angle is expected to be expressed in
radians.


<?
//prints 1.5574077246549
print(tan(1));
?>


Random Numbers


The following functions help you generate pseudorandom numbers. There are wrappers
for the randomizing functions offered by your operating system, and there are functions
based on the Mersenne Twister algorithm. The Mersenne Twister functions are faster and
return numbers with a much better distribution suitable for cryptographic applications.
The algorithm was developed by Makoto Matsumoto and Takuji Nishimura. You can
read more about it on their Web page http://www.math.keio.ac.jp/~matumoto/emt.
html. Pedro Melo refactored an implementation by Shawn Cokus in order to add support
to PHP.


integer getrandmax()


The getrandmax function returns the maximum random number that may be returned by
the rand function.

Free download pdf