Numbers in PHP

 PHP Integers

Check if variable type is Integer

<?php
$x = 5985;
var_dump(is_int($x));

$x = 59.85;
var_dump(is_int($x));
?>

PHP Floats

Check if variable type is Floats

<?php
$x = 10.365;
var_dump(is_float($x));
?>

PHP Infinity

Check if value in infinite or finite

<?php
$x = 1.9e411;
var_dump($x);
?>

PHP NAN

Check if invalid calculation it return NAN

<?php
$x = acos(8);
var_dump($x);
?>

PHP Numerical String

<?php
$x = 5985;
var_dump(is_numeric($x));

$x = "5985";
var_dump(is_numeric($x));

$x = "59.85" + 100;
var_dump(is_numeric($x));

$x = "Hello";
var_dump(is_numeric($x));
?>


Thanks for Reading. I hope it helps.

Want to donate. Donate me Here

Comments

Popular posts from this blog

PHP Variables

PHP Comments

PHP Operators