Saturday, January 31, 2009

Mathematical Functions

abs --> Returns the absolute value of number.
Format: $absolute = abs(number);
bindec --> Converts binary to a decimal value.
Format: $number_decimal = bindec(binary);
exp --> Returns the constant e raised to the power specified in exponent.
Format: $number = exp(exponent);
floor --> Rounds float to the next lower integer.
Format: $int = floor(float);
hexdec --> Converts hex (a number in hexadecimal form) to decimal.
Format: $number_decimal = hexdec(hex);
log --> Returns the natural log of number.
Format: $log = log(number);
log10 --> Returns the base-10 logarithm of number.
Format: $log10 = log10(number);
max --> Returns the largest number found in an array or a list of numbers.
Format: $num_large = max($array); or $num_large = max(num1,num2,. . .);
min --> Returns the smallest number found in an array or a list of numbers.
Format: $num_min = min($array); or $num_min = min(num1,num2, . . .);
number_format
Formats a number with specified decimal (dec) and thousands separators (thous). The default is a standard decimal point (.) and a comma (,) for the thousands separators.
Format: $formatted = number_format(number,”dec”’,”thous”);
octdec --> Converts a number in octal form to decimal form.
Format: $number_decimal = octdec(octal);
pow --> Returns number raised to power.
Format: $result = pow(number,power);
rand --> Returns a random number between min and max.
Format: $number_rand = rand(min,max);
round --> Rounds number to the nearest number with the specified number of decimal places.
Format: $result = round(number,dec);
sqrt --> Returns the square root of number.
Format: $square_root = sqrt(number);

srand --> Seeds the random number generator with seed.
Format: srand(seed);
PHP Options and Information Functions This section contains functions that work with PHP options and information.
getenv --> Returns the value of an environmental variable.
Format: $environment_value = getenv(“envvarname”);
getlastmod --> Gets the time that the current script was last modified.
Format: $timestamp = getlastmod();
ini_get --> Gets the value for a configuration option.
Format: $string = ini_get(“option”);
ini_set --> Sets the value of a configuration option.
Format: ini_set(“option”,”setting”);
phpinfo --> Outputs information about your PHP version and settings.
Format: phpinfo();
phpversion --> Returns the current PHP version.
Format: $version = phpversion();
putenv
Sets an environments variable. The value indicated in setting is usually in the form name=value.
Format: putenv(“setting”);

No comments:

Post a Comment