2.3. Variables

Although you've seen variables in the previous pages, you may wonder what they are exactly. Variables in PHP give you access to memory storage in a part of a computer called RAM, or random access memory. RAM is a volatile medium for storing information. That is, it all disappears when you shut off the machine. The computer sees this memory as a long array of memory cells that reside in sequential addresses. In PHP, however, you cannot actually get to memory at this level. You must use a variable. When you assign a value to a variable with $result = 2 + 5, or retrieve the value of a variable with print($result), PHP takes care of matching the variable name you specified with the right piece of memory in RAM.

Every use of a variable ...

Get Core PHP Programming, Third 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.