-
Book Overview & Buying
-
Table Of Contents
The Art of Modern PHP 8
By :
The first kind of type to get your head around is what is called "scalar." This is a fancy way of saying "simple." The best way to think of "scalar" types is as opposed to "compound" types. A scalar is not made of anything else; it is the smallest unit of data.
According to someone more learned than me on Stack Overflow, the term "scalar" comes from linear algebra, where it means a single number as opposed to a vector or matrix. I'm not a linear algebra specialist, so let's just take it that scalar means the opposite of complex.
The scalar types are as follows:
stringintfloatboolIf you want to check dynamically whether a variable is scalar, PHP has a function for that:
PHP: is_scalar - Manual
https://www.php.net/manual/en/function.is-scalar.php
Let's have a quick look through the scalar types in PHP.
String is the name for textual content. You tend...