About Numbers
When I began discussing variables, I was explicit in stating that PHP has both integer and floating-point (decimal) number types. In my experience, though, these two types can be classified under the generic title numbers without losing any valuable distinction. Valid number-type variables in PHP can be anything like
8
3.14
10980843985
-4.2398508
Notice that these values are never quoted—in which case they’d be strings with numeric values—nor do they include commas to indicate thousands. Also, a number is assumed to be positive unless it is preceded by the minus sign (-).
Along with the standard arithmetic operators you can use on numbers (Table 1.1), there are dozens of functions. Two I’ll introduce here are round() and number_format() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access