From the course: PHP for Web Designers

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Using variables to store information

Using variables to store information - PHP Tutorial

From the course: PHP for Web Designers

Start my 1-month free trial

Using variables to store information

One of the most important features of the programming language like PHP is the use of variables to store values that might change or aren't known in advance. If you've done any work with Javascript much of this will be familiar to you but there are some important differences. Even if you don't know any other programming language You use variables all the time, without even realizing it. For example, what's your name? My name's David, but my producer's name is Scott. The word name is a real-life variable. Name always remains the same, but its value changes. Let's look at some other real-life examples of variables. What day is it? What's the distance? Which city are you going to? To convert these real-life variables into PHP variables, just stick a dollar sign at the beginning of the word. A PHP script can then change the value of the variable, depending on who's logged into a website, name might become David, Scott, or Linda. PHP is capable of working out the current day or date. So…

Contents