-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84ddaf2
commit f542ee3
Showing
1 changed file
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
|
||
/* | ||
* There are three main numeric types in PHP: | ||
* Integer | ||
* Float | ||
* Number Strings | ||
* | ||
* In addition, PHP has two more data types used for numbers: | ||
* Infinity | ||
* NaN | ||
* */ | ||
|
||
|
||
$total_flats = 2; | ||
$per_flat_price = 5000.00; | ||
$total_price = "1e4"; | ||
$final = 2 * $total_price; // returns float | ||
|
||
var_dump($total_flats, $per_flat_price, $total_price, $final); | ||
|
||
echo '<pre>'; | ||
echo '===== Check integer ===='; | ||
echo '<pre>'; | ||
|
||
/* | ||
* Check integer | ||
* is_int() | ||
* is_integer() - alias of is_int() | ||
* is_long() - alias of is_int() | ||
* */ | ||
|
||
$x = 5985; | ||
var_dump(is_int($x)); | ||
|
||
$y = 59.85; | ||
var_dump(is_int($y)); | ||
|
||
|
||
echo '<pre>'; | ||
echo '===== Check Float ===='; | ||
echo '<pre>'; | ||
|
||
/* | ||
* Check Float | ||
* is_float() | ||
* is_double() - alias of is_float() | ||
* */ | ||
|
||
$x = 10.365; | ||
var_dump(is_float($x)); | ||
|
||
echo '<pre>'; | ||
echo '===== Check Numeric ===='; | ||
echo '<pre>'; | ||
|
||
|
||
/* | ||
* Check Numeric | ||
* is_numeric() | ||
* */ | ||
|
||
$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)); | ||
|
||
echo '<pre>'; | ||
echo '===== Check Infinity ===='; | ||
echo '<pre>'; | ||
|
||
/* | ||
* Check Infinity | ||
* is_finite() | ||
* is_infinite() | ||
* */ | ||
|
||
$x = 1.9e411; | ||
var_dump($x); | ||
var_dump(is_finite($x)); | ||
var_dump(is_infinite($x)); | ||
|
||
echo '<pre>'; | ||
echo '===== Check NaN ===='; | ||
echo '<pre>'; | ||
|
||
/* | ||
* Check NaN | ||
* is_nan() | ||
* */ | ||
|
||
$x = acos(8); | ||
var_dump($x); | ||
var_dump(is_nan($x)); |