PHP - Introduction and How To Set Up a Local Server To Test PHP Scripts - Just a test blog
That's all folks!

PHP is a server-side programing language used for general purpose programming and web development. It's creator Rasmus Lerdorf created PHP in 1995 and since then it has been installed in 244 million websites and 2.1 million web servers.

Some things that you should aware of about PHP is that it can directly be embedded into main HTML documents, and PHP code is impossible to read from client-side because PHP code runs on the server and only the result is send to the client.

How To Set Up a Local Server To Test PHP Scripts:

So, how do you run PHP scripts on your browser and test out some of it's cool features? Well, it's not quite like HTML or JavaScript where you can just create their file extension documents (.html and .js) and implement your code.

PHP scripts run only on server which has PHP plugin installed, so you first have to make a server, follow the steps below:

First, for the server, I recommend you download and install WAMP for Windows and MAMP for Mac. I use WAMP because I have a windows PC, so don't get confused with WAMP and MAMP they're both identical softwares with same functions.

Second, after you've installed WAMP, run it and left click on it's icon in the tray bar and select 'localhost' from the top:

A page will open looking something like this:

That is just to make sure if you've correctly installed the local webserver.

Third, now you have to locate the local directory where all the .php files will be stored to run, for the again left click on WAMP icon in tray and select 'www directory':

If something goes wrong and it gives an error, goto you wamp directory in "C:\wamp\www" and open the 'www' folder, you should have all the server files there.

Fourth, you should have a 'index.php' inside the root directory, open it with Notepad++ or just simple notepad. (though, I recommend you use notepad++, it's quite helpful)

Fifth, delete all the text in 'index.php' and copy & paste the code below in there:

<title>PHP Script</title>


   echo "Hello, World";



Sixth, now save it (ctrl+s) and goto your wamp icon again the tray and open 'localhost' or if you already have it open, refresh it and it shall say "Hello, World!".

Now I'm going to explain some very basics of what's happening above, first you have your basic HTML coding, the <html>, <head> and <body> tags, and in the body you have the PHP magic happening,

PHP is recognized, or starts with "<?php" tag and ends with "?>" tag, as I've mentioned above, PHP script can be written anywhere in the HTML document but the document should be on the server with PHP installed.

After '<?php' tag I've created an 'echo' command which is putting out "Hello, World" and ending with a semi-colon, remember semi-colons are vital when writing PHP codes, if you forget to put one semi-colon in your script, it won't work.

If you have any questions or anything, Please let us know below.