Php Tutorial – CHAPTER 2: Defining variables in PHP
Something that is universally use almost by every programming language
and scripting language is the definition of variables. The variables
are used to store different type of values such as numbers, functions,
strings and others. In PHP is very simple define variables. Something
you must have in mind in that in PHP variables are defining by the use
of this symbol “$”. It is the money or dollar symbol that is used in
PHP to define a variable. Let’s see in the practice how it works.
$variable_name = value;
It is as simple as that. Let’s see now how you can define a real
variable within a PHP or HTML document.
<html> <head> <title> MY OWN PHP SCRIPT </title> </head> <body> <?php $MSG = “It is a PHP Tutorial”; $Yr = 2008; ?> </body> </html>
When you run this script you will see as result a message saying “It is
a PHP Tutorial” and the current year that is “2008”. When you are
defining variables you must have to follow some simple rules. For
instance never start a variable using a number. PHP only accepts
variable names which start with a letter or with an underscores
character. Also a variable name can’t be written with spaces.

November 29th, 2009 at 5:49 am
Thanks, this is beginners tutorial.