Variable Creation and Scope

Although you've seen variables in the previous pages, you may wonder what they are exactly. Part of a computer is called RAM, or random access memory. This 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 string of single characters, or bytes, each numbered. In PHP, however, you cannot actually get to memory at this level. You must use a variable. You provide a name, and PHP takes care of matching the name to physical memory.

Listing 2.2. Experimenting with Scope
						
							
								
							
						
					

You do not need to let PHP know about a variable before you ...

Get Core PHP Programming: Using PHP to Build Dynamic Web Sites 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.