PHP| PHP for Beginners| PHP Examples| Date Functions| PHP MySQL| Questions? | Software Development
 

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:

<?php

$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/>";

$var=121;

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

?>

Output:

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

                         

» View all related tutorials
Related Tags:

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.