Login |  Register 
Your PHP skills tool showed me were I needed to improve and how to do it!
Tom
 

Variables

You can add a variable value to normal string like so.
var $text = "Welcome ";
var $name = 'Tom';
echo $text . $name;

There are several things to notice var indicates a variable decleration. We will discuss protection modifiers when we move on to object orientation.

The dollar sign $ indicates a variable with the rest of the word the variabe name. As PHP is weakley typed any value can be assigned to a variable be it a string, integer or array etc.

The next thing to notice is that there are two strings "Welcome" and 'Tom', however both these strings use two different forms of quotation. These quotes are largely interchangable as long as you start and end the string with the same form of quotes.

The last important item is the concatanation operator . This joins together the two strings so that Welcome Tom is outputted.

An alternative to echo is to use print which essentially does the same thing.

print "Hello";

Comments to date: 2. Page 1 of 1. Average Rating:
Sm   12:17pm on Sunday, September 25th, 2011 
var keyword is not needed iphp 5.
swan yi   8:07pm on Thursday, August 4th, 2011 
hi how are u?

security image
Written by Dominic Skinner
Last Updated: 2011-10-25 16:00:38