PHP Tutorial 03: Numeric Value.

PHP Numbers.

PHP Tutorial 03 Basic Information numeric value is discussing about the Integer.

  1. Store the values of numbers.
  2. Php integer containing whole numbers except of the decimals or floats.
  3. This can be positive or negative.
  4. Must have at least one number.
  5. 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.

  1. The numerica value larger than the php-float_max is considering as the infinite.
  2. The php has two types of function two check the number is infinite or not.
  1. PHP var_dump() this function is using to return the data type and value.
  2. is_nan() function is using to check the value is number or not.

is_finite()
is_infinite()

  1. is_numeric() function is using to check the variable is numeric or not in the php code.
  2. 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 Tutorial 03 Basic Information
  • 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 Tutorial 03 Basic Information
  • PHP_abs() function is using to find the positive value of the number.
PHP Tutorial 03 Basic Information
  • PHP_squart() function is using to find the square root of the number.
PHP Tutorial 03 Basic Information
  • PHP_round() Function is using to find the floating point number to nearest integer.
PHP Tutorial 03 Basic Information

PHP Tutorial 02.

One thought on “PHP Tutorial 03: Numeric Value.”

Leave a Reply

Your email address will not be published. Required fields are marked *