From the course: PHP for Non-Programmers
Unlock the full course today
Join today to access over 25,200 courses taught by industry experts.
What are variables? - PHP Tutorial
From the course: PHP for Non-Programmers
What are variables?
- [Narrator] Printing information onto the screen is great, but we don't always know exactly what information we need to print when we're writing our code. For example, if we want to print the visitor's name, there's no possible way of knowing that information before they visit. That's where variables come in. Variables are a way to store information in order to reference it later. Variables can be used to store names, numbers, and other important data. Variables must start with a dollar sign followed by a letter or underscore, then an alpha numeric character string. Here's an example, age, the equal sign, 36, and then the semicolon. Age is a placeholder for that which we have stored, the number 36. PHP knows age is 36 because of the equal sign, which means is assigned to or gets. I'll usually say gets when referring to variables. We can then use age as if it's the number 36, printing it or even doing calculations on…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.