PHP Getting Started

Install Wampserver or XAMPP on your PC to quickly create web applications with Apache, PHP and a MySQL database.

Getting Started with PHP

Here, you will learn how easy it is to create dynamic web pages using PHP. Before begin, be sure to have a code editor and some working knowledge of HTML and CSS.

If you're just starting out in web development, start learning from here »

OK, let's get straight into it.

Setting Up a Local Web Server

PHP script execute on a web server running PHP. So before you start writing any PHP program you need the following program installed on your computer.

  • The Apache Web server
  • The PHP engine
  • The MySQL database server

You can either install them individually or choose a pre-configured package for your operating system like Linux and Windows. Popular pre-configured package are XAMPP and WampServer.

WampServer is a Windows web development environment. It allows you to create web applications with Apache2, PHP and a MySQL database. It will also provide the MySQL administrative tool PhpMyAdmin to easily manage your databases using a web browser.

The official website for downloading and installation instructions for the WampServer:

Creating Your First PHP Script

Now that you have successfully installed WampServer on your computer. In this section we will create a very simple PHP script that displays the text "Hello, world!" in the browser window. Ok, click on the WampServer icon somewhere on your Windows task bar and select the "www directory". Alternatively you can access the "www" directory through C:\wamp\www. Create a subdirectory in "www" let's say "project".

Now open up your favorite code editor and create a new PHP file. Start with an empty window and type the following code:

  • <?php
  • // Simple greeting message
  • echo "Hello, world!";
  • ?>

Now save this file as "hello.php" in your project folder (located at C:\wamp\www\project), and view the result in your browser through visiting this URL: http://localhost/project/hello.php. Alternatively you can access the "hello.php" file through selecting the localhost option from the WampSever menu on the taskbar.

In the next chapter you will learn about the PHP syntax.


Your Feedback:


We would love to hear from you! Please say something.