Chapter 5 Variables and Constants

5.1 What is a Variable?

In computer science, a variable is a location in the computer's main memory (RAM) where a program (or script) can store a value and change it as the program/script executes.

Picture a variable as a transparent box in which you can insert and hold one thing at a time. Because the box is transparent, you can also see what it contains. Also, if you have two or more boxes you can give each box a unique name. For example, you could have three boxes, each containing a different number, and you could name the boxes numberA, numberB, and numberC.

Image

The boxes named numberA, numberB and numberC in ...

Get PHP and Algorithmic Thinking for the Complete Beginner 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.