2.2. Variables and Datatypes

So far, you've learned how to output data, as well as how to use variables to a certain extent. Before going any further, let's take a moment to drill down on variables and how they work.

2.2.1. What Is a Variable?

A variable is a keyword or phrase that acts as an identifier for a value stored in a system's memory. This is useful because it allows us to write programs that will perform a set of actions on a variable value, which means you can change the output of the program simply by changing the variable, rather than changing the program itself.

2.2.2. Storing Values in a Variable

PHP lets you store nearly anything in a variable using one of the following datatypes:

String: Alphanumeric characters, such as sentences ...

Get PHP for Absolute Beginners 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.