#native_company# #native_desc#
#native_cta#

The ABC’s of PHP Part 4 – How Variable Am I?

By PHP Builder Staff
on April 1, 2009

That’s a very good question, just how variable are you?
To many beginners the subject of variables is usually pretty
scary, and often a reasonably difficult concept to grasp,
the reason for this however is usually because most modern
languages require some kind of indication as to what type of
data a variable will hold, this in turn often confuses
beginners because they don’t know what type of data relates
to what kind of type.
The good thing about PHP is that this is not required,
instead PHP is smart enough to work out how to handle your
data automatically all you have to do is assign a value.
However, before we get to that point??..
What is a variable?
Put simply, a variable is an area of memory that has a
convenient name assigned to it, this area of memory can then
be used to store any data related to your script for further
use later in your script.
Under PHP, variables are indicated by prefixing the name with
a dollar sign. So for example to declare a variable that
might be used to hold a name you might use:

$name = "peter";
In the above case PHP assigns a string of data containing
the word “peter” to a memory address and then points the
identifier $name to it so that’s it’s easy to remember and
use.
Some other examples of variable usage are as follows:

$age = 21;
$date = "19/02/2009";

1
|
2
|
3
|
4