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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.