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

Using variables - PHP Tutorial

From the course: Learning PHP

Start my 1-month free trial

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…

Contents