Pages

Monday 4 July 2011

A short miss spelt introducan to server side scripting in PHP

I asume you have a basic understanding of HTML, if not you can find plent of turoials on the web, personaly i reeocomend W3Schools tutorial.

PHP is a gernral perpos scripting langwage, but its most common use is scripting on web servers. This is a short introducon to it and we wont go into to much detal.

Befor you use PHP you need a server to run it on. Insted of having a hole seprat computer to act as a server, or even runing a veutal masheen the simplast way by far is to use a local server or local host, this terns you home computer into a web server. I use xampp for this but ther is menny of them out ther like wamp for windows and so on. I will let you find out how to run thes your self, ther is pleny of tutorisals out ther. IF i was to explane it it wold probalby end up going in to way to much deatal.

So now you have a way to render the PHP. When you are working with PHP all files contaning PHP must be saved as '.php'. As always with lerning a new programing langwige it is common pracktis to make a hello world program. so coppy the folowing code into a text editer and i will try to explane what is going on.
<?php
echo "hello world";
?>
One you acsess the file thrue your web server you will see the output is hello world. on starting a PHP script you use the "<?php" tag and you end it with "?>". the echo part of it is just like saying print in basic or cout in c++. at the end of a coded line it ended with a semicolon(";") this just tells PHP that it is the end of a line.

Now lets try a more complacated hello world program.
<?php
$a = "hello";
$b = "world";
echo $a." ".$b;
?>
 This file has exactly the same out put as befor. but this time we are using verables. when using verables in PHP the verable name always starts with a '$'. in this case we are usesing strings so the value of the verable must be sorounded by quotatons. on the echo line we use a '.' to concatanate the strings.

Thank you for reading, i know that this is a lital confusing but once you get your head around it it can be very simple.

George out.

No comments:

Post a Comment

Powered By Blogger