1. Trang chủ
  2. » Công Nghệ Thông Tin

PHP Developer''''s Dictionary- P28 potx

5 281 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 361,79 KB

Nội dung

PHP Developer’s Dictionary IT-SC book 135 getrandmax() Syntax int getrandmax(void) Description The getrandmax() function returns the maximum value that can be returned by a call to rand(). hexdec() Syntax int hexdec(string hex_string) Description The hexdec() function returns the decimal equivalent of the hexadecimal number represented by hex_string . The largest number that can be converted is 7fffffff in hex, which equates to 2,147,483,647 in decimal. log() Syntax float log(float arg) Description The log() function returns the natural log of arg . echo log(2.718);//returns ~ 1 log10() PHP Developer’s Dictionary IT-SC book 136 Syntax float log10(float arg) Description The log10() function returns the base 10 logarithm of arg . echo log10(100);//returns 2 max() Syntax mixed max(mixed arg1, mixed arg2, mixed argn) Description The max() function examines the parameter list and returns the numerically highest parameter. If arg1 is an array, the highest value in the array will be returned. If arg1 is an integer, string, or double, you need at least two parameters, and max() returns the largest of these values. You can compare an unlimited number of values. If one or more of the parameters are of type double, all the parameters will be treated as doubles, and the return value will be a double. If none of the parameters is a double, they all will be treated as integers, and the return value will be an integer. min() Syntax mixed min(mixed arg1, mixed arg2, mixed argn) Description The min() function examines the parameter list and returns the numerically lowest parameter. If arg1 is an array, the lowest value in the array will be returned. If arg1 is an integer, string, or double, you need at least two parameters and min() returns the smallest of these values. You can compare an unlimited number of values. PHP Developer’s Dictionary IT-SC book 137 If one or more of the parameters are of type double, all the parameters will be treated as doubles, and the value returned will be a double. If none of the parameters is of type double, they all will be treated as integers, and the value returned will be an integer. mt_rand() Syntax int mt_rand( [int min] , [int max] ) Description The mt_rand() function, which was added in PHP 3.0.6 and PHP 4.0, returns a random number utilizing the Mersenne Twister method for generating random numbers instead of the standard libc library. The optional parameters of min and max specify a range you want the random number to fall between (range is inclusive). Note that you should provide a seed before utilizing any random number functions. For more information, check out http://www.math.keio.ac.jp/~matumoto/emt.html . The source for MT is available at http://www.scp.syr.edu/~marc/hawk/twister.html . mt_srand() Syntax void mt_srand(int seed) Description The mt_srand() function, which was added in PHP 3.0.6 and PHP 4.0, seeds the random number generator with seed . This allows the random number generating functions to produce varying results depending on what seed is given. mt_getrandmax() Syntax int mt_getrandmax(void ) Description PHP Developer’s Dictionary IT-SC book 138 The mt_getrandmax() function, which was added in PHP 3.0.6 and PHP 4.0, returns the maximum value that can be returned by a call to mt_rand() . number_format() Syntax string number_format(float number, int decimals, string dec_point, string thousands_sep) Description The number_format() function returns a formatted version of number based on the formatting information supplied in the other parameters. If only one parameter is given, number will be formatted with a comma as the thousands separator character. Two parameters indicate that the number should be formatted with the parameter decimals number of decimal places after the decimal point. Also, a comma will be used as the thousands separator character. Four parameters indicate that number should be formatted with the parameter decimals number of decimal places. Also, dec_point indicates the character that should be used in the decimal point location, namely the separator between the ones and tenths positions. Finally, the thousands_sep indicates which character should be used to indicate a group of thousands. In the United States, the decimal point is typically specified as " . " and the thousands separator is specified as " , ", but in some countries these are reversed. octdec() Syntax int octdec(string octal_string) Description The octdec() function returns the decimal equivalent of octal_string , which represents an octal number. The largest number that can be converted is 17777777777 octal or 2,147,483,647 in decimal. pi() Syntax PHP Developer’s Dictionary IT-SC book 139 double pi(void ) Description The pi() function returns an approximate value of pi. pow() Syntax float pow(float base, float exp) Description The pow() function returns the base raised to the power of exp . echo pow(2,3);//returns 8 rad2deg() Syntax double rad2deg(double number) Description The rad2deg() function , which was added in PHP 3.0.4 and PHP 4.0, takes a number specified in radians and returns its value in degrees. echo rad2deg(pi());//displays 180 rand() Syntax int rand ([int min [, int max]]) . int mt_getrandmax(void ) Description PHP Developer’s Dictionary IT-SC book 138 The mt_getrandmax() function, which was added in PHP 3.0.6 and PHP 4.0, returns the maximum value that. void mt_srand(int seed) Description The mt_srand() function, which was added in PHP 3.0.6 and PHP 4.0, seeds the random number generator with seed . This allows the random number. mt_rand( [int min] , [int max] ) Description The mt_rand() function, which was added in PHP 3.0.6 and PHP 4.0, returns a random number utilizing the Mersenne Twister method for generating random

Ngày đăng: 07/07/2014, 05:20