Difference between revisions of "Variables in PHP"
From OdleWiki
m (→Basics) |
m (Added "Needs Attention" template) |
||
Line 1: | Line 1: | ||
+ | {{Template:Needs Attention}} | ||
{{Template:PHP4 5}} | {{Template:PHP4 5}} | ||
[[Category:PHP]] | [[Category:PHP]] | ||
− | |||
== Basics == | == Basics == | ||
Latest revision as of 18:02, 8 July 2017
Contents
Basics
Variables in PHP:
- are always preceded by a dollar sign ($)
- start with a letter or underscore (_)
- may contain any number of letters, numbers, and underscores
- are case-sensitive
Examples of Acceptable Variable Names
$var $_var $_Var $VAR $VAR_001
This is not a comprehensive list, merely examples.
Examples of Unacceptable Variable Names
$var*
(Variable names may only contain letters, numbers, and underscores.)
$var #1
(Variable names may not contain # or spaces.)
var$
(Variables names must begin with a dollar sign.)
Types of Variables
Assigning Values to Variables
To assign a value to a variable, use a single equal sign (=)
$var = "Hello, world."