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!

Variables in PHP

From OdleWiki

Farm-Fresh cup edit.png

Needs Attention
This article needs attention; however, it is not necessarily a stub or an orphan.


This page describes documentation valid for PHP 4 and PHP 5.


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


This is not a comprehensive list, merely examples.

Examples of Unacceptable Variable Names


(Variable names may only contain letters, numbers, and underscores.)

$var #1

(Variable names may not contain # or spaces.)


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