PHP - Variables

Document Sample
PHP - Variables Powered By Docstoc
					                                    PHP Variables
A variable can store the value of any data type.

The variable can be declared as follows:

          $var_name = value;

All variables in php must be preceded by a dollar sign ($).

A variable can store value of any data type ie. Numbers, string of characters,
objects, arrays or boolean.

The value of variable can be changed at any time and can be used over and over
again in a script.

Let us see a script below to demonstrate usage of variable:

<?php

          $var = “Hello World”;

          echo $var;

?>

Rules for naming variables:

     1.   A variable name is always preceded by dollar sign ($).
     2.   A variable name can include letters, numbers and underscores (_).
     3.   A variable name must not contain any spaces.
     4.   A variable must begin with letter or underscore (_).

Check our more tutorials at http://unettuts.com




© unettuts, 2011                                                 http://unettuts.com

				
DOCUMENT INFO
Shared By:
Stats:
views:19
posted:8/23/2011
language:English
pages:1
Description: Learn how to use variables in php.