Originally published on zero2php.dev — part of the Zero to PHP course. View this lesson on the original site.
Scalars at a glance
Common scalar types you will use immediately:
| Type | Examples |
|---|---|
| int | 0, -3, 42 |
| float | 1.25, 3.0 |
| string | 'hi', "count=$count" |
| bool | true, false |
| null | null |
Arrays and objects come in later chapters in depth; you should still recognize their names now.
Inspecting values
Use var_dump($x) while learning to see type and value together.
Exercise
Show that numeric strings add like numbers: set $a = '5' and $b = '5', then echo $a + $b so the output is 10.
From Zero to PHP — PHP foundations: environment, syntax, and values