PHP & MySQL® Web Development All-in-One Desk Reference for Dummies®
by Janet Valade, Tricia Ballad, Bill Ballad
1.6. Using PHP Variables
Variables are containers used to hold information. A variable has a name, and information is stored in the variable. For instance, you might name a variable $age and store the number 12 in it. After information is stored in a variable, it can be used later in the script. One of the most common uses for variables is to hold the information that a user types into a form.
1.6.1. Naming a variable
When you're naming a variable, keep the following rules in mind:
All variable names have a dollar sign ($) in front of them. This tells PHP that it is a variable name.
Variable names can be any length.
Variable names can include letters, numbers, and underscores only.
Variable names must begin with a letter or an underscore. They cannot begin with a number.
Uppercase and lowercase letters are not the same. For example, $firstname and $Firstname are not the same variable. If you store information in $firstname, for example, you can't access that information by using the variable name $firstName.
|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
