What Are Variables?

Variables, in short, are containers used to temporarily store values. These values can be numbers, text, or much more complex arrangements. Variables 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 type that has no value).

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

  • A variable’s name—also ...

Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition 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.