Monday, February 7, 2011

Step#3 Variables in PHP

Variables are used for storing values, like text strings, numbers or arrays.


When a variable is declared, it can be used over and over again in your script.
All variables in PHP start with a $ sign symbol.

The correct way of declaring a variable in PHP:

$var_name = value;    

New PHP programmers often forget the $ sign at the beginning of the variable. In that case it will not work.
Let's try creating a variable containing a string, and a variable containing a number:

<?php
$txt="Hello World!";
$x=16;
?>

No comments:

Post a Comment