This wiki is for the exclusive use of my friends and colleagues. Account creation and anonymous editing have been turned off.

If you are a friend or colleague of mine, and would like to participate in this project, please send me a message.

If you find these pages useful, please donate to help cover server costs. Thanks!

Difference between revisions of "Variables in PHP"

From OdleWiki
(Created page with "== Basics == Variables in PHP: #always begin with a dollar sign ($) #starts with a letter or underscore (_) #may contain any number of letters, numbers, and underscores #are...")
 
Line 1: Line 1:
 +
[[Category:PHP]]
 +
[[Category:Articles_needing_attention]]
 
== Basics ==
 
== Basics ==
  
Line 25: Line 27:
  
  
==Types of Variable==
+
==Types of Variables==
  
 
== Assigning Values to Variables ==
 
== Assigning Values to Variables ==

Revision as of 15:15, 30 July 2012

Basics

Variables in PHP:

  1. always begin with a dollar sign ($)
  2. starts with a letter or underscore (_)
  3. may contain any number of letters, numbers, and underscores
  4. are case-sensitive

Acceptable Variable Names

$var $_var $_Var $VAR $VAR_001

This is not a comprehensive list, merely examples.

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."