PHP Numbers.
PHP Tutorial 03 Basic Information numeric value is discussing about the Integer.
- Store the values of numbers.
- Php integer containing whole numbers except of the decimals or floats.
- This can be positive or negative.
- Must have at least one number.
- Integers have three types of predefined constants. Such as,
- Php_Int-max – Select the biggest integer.
- Php_int_min, – Select the smallest integer
- Php_int_size.- Select the size of interger in byte.
Php have some function to check the given number is integer or not. That functions are,
- is_int()
- is_integer()
- is_long()
PHP floats.
- This contains decimal point or a number in exponential form.
- This float has constants. Such as,
- Php_Float_max – Largest floating-point number.
- Php_Float_min – Smallest floating-point number.
- -Php_Float_max – Smallest negative representation number.
- Php_Float_Dig – Rounded the decimal numbers.
- Php_Float_Epsilon – Smallest positive float number y such as, y + 2.0!= 2.0
PHP Tutorial 03 Basic Information is also have function to check the given number is float or not. That functions are,
- is_float()
- is_double() – alias of is_float()
PHP Infinity.
- The numerica value larger than the php-float_max is considering as the infinite.
- The php has two types of function two check the number is infinite or not.
- PHP var_dump() this function is using to return the data type and value.
- is_nan() function is using to check the value is number or not.
is_finite()
is_infinite()
- is_numeric() function is using to check the variable is numeric or not in the php code.
- PHP numeric values can convert to one data type to another data types, For this we can use int_cast() function.
<?php
// Cast float to integer
$y = 1234.456;
$int_cast = (int)$y;
echo $int_cast;
echo "<br>";
// Cast string to integer
$y = "12345.673";
$int_cast = (int)$y;
echo $int_cast;
?>
PHP Tutorial 03 Mathematics.
- PHP_min() function is using to find the largest value in the argument.
- PHP_max() function is using to find the smallest value in the argument.
- PHP_abs() function is using to find the positive value of the number.
- PHP_squart() function is using to find the square root of the number.
- PHP_round() Function is using to find the floating point number to nearest integer.
One thought on “PHP Tutorial 03: Numeric Value.”