O'Reilly logo

PHP Quick Scripting Reference by Mikael Olsson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 2

image

Variables

Variables are used for storing data, such as numbers or strings, so that they can be used multiple times in a script.

Defining variables

A variable starts with a dollar sign ($) followed by an identifier , which is the name of the variable. A common naming convention for variables is to have each word initially capitalized, except for the first one.

$myVar;

A value can be assigned to a variable by using the equals sign, or assignment operator (=). The variable then becomes defined or initialized .

$myVar = 10;

Once a variable has been defined it can be used by referencing the variable’s name. For example, the value of the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required