From the course: Learning PHP
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using variables
- [Instructor] Printing information onto the screen is great, but we don't always know exactly what information we want to print while 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 numbers, names, or other important data. In PHP variables must start with a dollar sign, followed by a letter or an underscore, then an alphanumeric character string. Here's an example. You see that we have our opening PHP tags, a dollar sign followed by the word age, and then an equal sign, and some value, in this case 34, and we have our semi-colon. Age is a placeholder for the number that we have stored in it, which is 34. PHP knows age is 34 because of the equal sign, which means is assigned to or…
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.
Contents
-
-
-
How PHP works2m 29s
-
(Locked)
Printing on the screen3m 53s
-
(Locked)
Using variables6m 40s
-
(Locked)
Single vs. double quotes7m 3s
-
(Locked)
What are arrays and how do they work?3m 56s
-
(Locked)
Defining arrays8m 10s
-
(Locked)
Challenge: Display basic information on an HTML page36s
-
(Locked)
Solution: Display basic information on an HTML page2m 57s
-
-
-
-
-
-
-
-
-
-