So, to start off with, we need to tell the server that we are going to be using PHP. To do this, insert this code into your PHP document :


Code:
<?php

?>
That code has to be present on every piece of PHP code.

Right, we need to declare a variable. Those of you that are familiar with programming will get used to this quickly. If you aren't, don't worry you will soon get adjusted! So, were going to declare a variable, here we go :


Code:
$stringvariable = "Hello World!";
That code, declares a variable called "stringvariable" and assigns "Hello World!" to it. The "Hello World" can be anything you like. Now the one of the most important characters in that line of code is the ";". That semi-colon ( ; ) has to be at the end of every declaration, so get used to it! One of the most common mistakes for new programmers is forgetting to put the ; at the end!

So now, your code should look a lil' something like this :

Code:
<?php

$stringvariable = "Hello World!";

?>
So thats the declaration done. Now we want to print it!

Printing is rather easy, here we go :

Code:
<?php

$stringvariable = "Hello World!";
echo "$stringvariable";

?>
Notice the ; at the end of the code, again.
Also notice the quotes before $stringvariable, they do not need to be there, as you are echo'ing a variable. However, if you were echo'ing raw text they would need to be there!
The final output will be the following :


Code:
Hello World!
It doesn't seem like much, but you've just coded your first PHP script!

Important Note! : In this tutorial, I echo'd a variable. However, you are not limited to echo'ing variables, you can echo raw text. ie :

Code:
echo "Hello World!";
However, I wanted to show you how to declare a variable aswell as how to echo. Remember that!
Hope you enjoy reading this tutorial!