PHP Tutorial 1 – Getting started with PHP using WampServer2 on Windows 7

Hello all,

Here is the first of tutorials that I will make to cover the basics of PHP. My goal is not to have yet another tutorial-blog/site, but to show how I got started with PHP and eventually show some advanced things you can do with it. To reach that goal, I first want to introduce ‘newbies’ to PHP. In this tutorial I’m going to assume you have basic knowledge of HTML, which will be used sometimes in examples. If you don’t know HTML, I recommend visiting w3schools.com

What is PHP?

PHP is a scripting language which is used among others for creating dynamic web pages.

What does PHP stand for?

PHP stands for: Hypertext Preprocessor. You might ask me what the first P stands for… well, back in the days PHP used to mean: Personal Home Page, but then they wanted something more sophisticated and changed it a little while keeping the first P.

What can you do with it?

There infinitely many things you could do with PHP, but it comes down to this list of general subjects:

  • create dynamic web page
  • create web application
    • PhpMyAdmin (database management system)
  • create a CMS(content management system)
    • WordPress
    • Drupal
    • Joomla
  • create <script_name_here>

A nice example of a dynamic web page is this very Blog, written by the WordPress community volunteers in PHP. It’s simply a dynamic web page, with a back-end that allows login that provides access to a content management system designed to create a Blog or add pages, the wonderful thing about WordPress is that you can very easily use Plugins also written in PHP.

What do you need to get started?

To start using PHP on Windows, I recommend the following programs:

  • Apache webserver
  • PHP 5.3.0

You can download what is called a WAMP/LAMP stack. It’s a package that contains:

  • Apache
  • MySql
  • PHP

The W or L stands for Windows or Linux. So for the Windows users lets download my favorite WAMP stack: WampServer. After downloading follow these steps to install it:

WampServer2 Setup - Step 1
Press Next
WampServer2 Setup - Step 2
Click on "I accept the agreement" then press Next
WampServer2 Setup - Step 3
I recommend leaving this default, then press Next
WampServer2 Setup - Step 4
Choose what Icon's you want, then press Next
WampServer2 Setup - Step 5
Now press Install
WampServer2 Setup - Step 6
Please wait while Setup installs WampServer2 on your computer.
WampServer2 Setup - Step 7
Leave the default values and press Next
WampServer2 Setup - Step 8
Congratulations, you have WampServer2! Press Finish to Launch WampServer2 now.

So now that you have WampServer2, your ready to write your first PHP code!

First PHP code

If you left the default installation path, open up an explorer and go to C:/wamp/www/. Now create a new folder, I will call mine “firstPHP”. Now you should go into this folder: C:/wamp/www/firstPHP/. Fire up your favorite browser (you probably already did, because you are reading this text!). Open a new tab and goto: http://localhost

If all went well, you should now see this page:

WampServer overview including firstPHP folder
Here you can see the WampServer overview including your folder 'firstPHP' under Your Projects

Now that everything is setup right, lets finally write our first PHP code! Open up a notepad and write the following HTML code which contains a piece of PHP and save it as index.php in your firstPHP folder:

<html>
<head>
    <title>My First PHP</title>
</head>
<body>
<?php
echo "My First Php! Hello World is Lame!";
?>
</body>
</html>

After saving it, goto http://localhost/firstPHP/ and you should see this:

firstPHP
Your first PHP code

Summary

In this tutorial you have learned:

  • What PHP stands for
  • How to install WampServer2
  • How to write your first PHP code

Leave a Reply

Your email address will not be published. Required fields are marked *