File tree 1 file changed +101
-0
lines changed
1 file changed +101
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * There are three main numeric types in PHP:
5
+ * Integer
6
+ * Float
7
+ * Number Strings
8
+ *
9
+ * In addition, PHP has two more data types used for numbers:
10
+ * Infinity
11
+ * NaN
12
+ * */
13
+
14
+
15
+ $ total_flats = 2 ;
16
+ $ per_flat_price = 5000.00 ;
17
+ $ total_price = "1e4 " ;
18
+ $ final = 2 * $ total_price ; // returns float
19
+
20
+ var_dump ($ total_flats , $ per_flat_price , $ total_price , $ final );
21
+
22
+ echo '<pre> ' ;
23
+ echo '===== Check integer ==== ' ;
24
+ echo '<pre> ' ;
25
+
26
+ /*
27
+ * Check integer
28
+ * is_int()
29
+ * is_integer() - alias of is_int()
30
+ * is_long() - alias of is_int()
31
+ * */
32
+
33
+ $ x = 5985 ;
34
+ var_dump (is_int ($ x ));
35
+
36
+ $ y = 59.85 ;
37
+ var_dump (is_int ($ y ));
38
+
39
+
40
+ echo '<pre> ' ;
41
+ echo '===== Check Float ==== ' ;
42
+ echo '<pre> ' ;
43
+
44
+ /*
45
+ * Check Float
46
+ * is_float()
47
+ * is_double() - alias of is_float()
48
+ * */
49
+
50
+ $ x = 10.365 ;
51
+ var_dump (is_float ($ x ));
52
+
53
+ echo '<pre> ' ;
54
+ echo '===== Check Numeric ==== ' ;
55
+ echo '<pre> ' ;
56
+
57
+
58
+ /*
59
+ * Check Numeric
60
+ * is_numeric()
61
+ * */
62
+
63
+ $ x = 5985 ;
64
+ var_dump (is_numeric ($ x ));
65
+
66
+ $ x = "5985 " ;
67
+ var_dump (is_numeric ($ x ));
68
+
69
+ $ x = "59.85 " + 100 ;
70
+ var_dump (is_numeric ($ x ));
71
+
72
+ $ x = "Hello " ;
73
+ var_dump (is_numeric ($ x ));
74
+
75
+ echo '<pre> ' ;
76
+ echo '===== Check Infinity ==== ' ;
77
+ echo '<pre> ' ;
78
+
79
+ /*
80
+ * Check Infinity
81
+ * is_finite()
82
+ * is_infinite()
83
+ * */
84
+
85
+ $ x = 1.9e411 ;
86
+ var_dump ($ x );
87
+ var_dump (is_finite ($ x ));
88
+ var_dump (is_infinite ($ x ));
89
+
90
+ echo '<pre> ' ;
91
+ echo '===== Check NaN ==== ' ;
92
+ echo '<pre> ' ;
93
+
94
+ /*
95
+ * Check NaN
96
+ * is_nan()
97
+ * */
98
+
99
+ $ x = acos (8 );
100
+ var_dump ($ x );
101
+ var_dump (is_nan ($ x ));
You can’t perform that action at this time.
0 commit comments