PHP Working with Variables Tutorial

Variables are one of the most important concepts of PHP, learn how to use them here.

PHP  variables


If you are planning to start writing in PHP you should  know what a variable is and how to use a variable..
Here is an example of a variable: $jim = "cricket";
What is a variable exactly? A variable is much like a container which can contain String, Integer, Float, Character or Boolean value.

All variables begin with the $ symbol followed immediately by a word which is known as the variables name. No characters or symbols are allowed inside the variables name other then NUMBERS, LETTERS, AND UNDERSCORE SYMBOL (an underscore is this: _ ).
Here is an example of proper syntax
This name would not be allowed: $stea7th owns
This one would though: $stea7th_owns
You must remember though that all variable names are case sensitive, so that means $stea7th and $STEA7TH are not the same. In PHP it is not required to declare any variable before we use it. PHP is loosely typed language, PHP depends on the  value not on the variable, it automagically converts a variable to different datatypes.

Some examples of variable declaration and use are given below:

Example 1:


$var="This is String value";

echo "<b>Value of \$var is $var</b><br/>";

echo "<b>Datatype of variables are dynamic in nature</b><br/>";


echo "<b>Value of \$var is $var</b><br/>";



Value of $var is: This is String value
Datatype of variables are dynamic in nature
Value of $var is: 121



We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.

Share on Google+Share on Google+

PHP Working with Variables Tutorial

Posted on: November 12, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: PHP Working with Variables Tutorial  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
Narsing Rao
July 29, 2011
Connection parameters

I am devoloped a website and it is running proparly in the internet but when i am trying to run that code on Wamp server Output is showing but it is connecting to database. Any one help to what are the connection parameters to connect with the database in PHP Thank you