What Are Variables?

Variables, in short, are widgets used to temporarily store values. These values can be numbers, text, or much more complex arrangements. They exist at the heart of any programming language and comprehending them is key to using PHP.

According to the PHP manual, there are eight types of variables in the language. These include four scalar (single-valued) types—Boolean (TRUE or FALSE), integer, floating point (decimals), and strings (text); two nonscalar (multivalued)—arrays and objects; plus resources (which you’ll see when interacting with databases) and NULL (which is a special variable that has no value).

Regardless of what type you are creating, all variables in PHP follow certain syntactical rules:

  • A variable’s name must ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.