abs(-4.2);
Finding the Absolute value of the given number.
<?php $absolute = abs(-8.21); print $absolute; $absolute = abs(8.21); print "
".$absolute; ?>
base_convert('A37334', 16, 2);
Converts the number from one base to another base.
<?php $hexadecimal = 'A37334'; print base_convert($hexadecimal, 16, 2); $strval = '50'; print "
".base_convert($strval, 10, 16); ?>
Other predefined base convertor functions are present in PHP like decbin(), bindec(), dechex(), hexdec(), decoct(), octdec()
floor(4.3);
floor(9.999);
floor(-3.14);
It prints the whole number part if the number is positive otherwise add -1 to the whole number part.
<?php print floor(4.3); print floor(9.999); print floor(-3.14); ?>
ceil(4.3);
ceil(9.999);
ceil(-3.14);
Returns the next highest integer value by rounding up value if necessary.
<?php print ceil(4.3); print ceil(9.999); print ceil(-3.14); ?>
is_finite(121323422323);
Checks the value is finite or not.
<?php print is_finite(1233); print "
".is_finite(log(0)); ?>
is_nan ( 5.1225 );
Returns TRUE if val is 'not a number', else FALSE.
<?php print is_nan(1233); print is_nan(acos(1.01)); ?>
max(1, 3, 5, 6, 7);
Finds the greatest value from the list of numbers.
<?php print max(1, 3, 5, 6, 7)."
"; print max(array(2, 4, 5))."
"; print max(0, 'hello')."
"; //Explanation is that :- Any Non numeric value treated as 0 ,So max and min function comparing from the left to right. print max('hello', 0)."
"; print max(-1, 'hello')."
"; // With multiple arrays, max compares from left to right // so in our Example: 2 == 2, but 4 < 5 $val = max(array(2, 4, 8), array(2, 5, 7)); print_r($val); print "
"; // If both an array and non-array are given, the array // is always returned as its seen as the largest $val1 = max('string', array(2, 5, 7), 42); print_r($val1); ?>
min(1, 3, 5, 6, 7);
Finds the smallest value from the list of numbers.
<?php print min(2, 3, 1, 6, 7)."
"; print min(array(2, 4, 5))."
"; print min(0, 'hello')."
"; print min('hello', 0)."
"; print min('hello', -1)."
"; // With multiple arrays, min compares from left to right // so in our Example: 2 == 2, but 4 < 5 $val = min(array(2, 4, 8), array(2, 5, 1)); print_r($val); print "
"; // If both an array and non-array are given, the array // is never returned as its considered the largest $val1 = min('string', array(2, 5, 7), 42); print_r($val1); ?>
rand(12,15);
Showing any random number between these two given number including two given number.
<?php print rand()."
"; print rand()."
"; print "minimum number is 5"."
"; print "maximum number is 15"."
"; $random = rand(5, 15); print "Random number is " .$random."
"; ?>
pow(8,2);
It finds the power of given base to the power.
<?php var_dump(pow(2, 8))."
"; print pow(-1, 20)."
"; print pow(0, 0)."
"; print pow(3,2); ?>
strtosqrt(9);
Finds the square root of a number.
<?php // Precision depends on your precision directive print sqrt(9)."
"; print sqrt(10)."
"; ?>
round(3.45);
Returns the rounded value of val to specified precision (number of digits after the decimal point). precision can also be negative or zero (default).
<?php echo round(3.4)."
"; echo round(3.5)."
"; echo round(3.6)."
"; echo round(3.6, 0)."
"; echo round(1.95583, 2)."
"; echo round(1241757, -3)."
"; echo round(5.045, 2)."
"; echo round(5.055, 2)."
"; ?>
After editing Click here: |
Output:
|
Hello World
|