A Brief First Tutorial on PHP by Jackline Hunter

In this brief tutorial, I'm going to show you how to get started with PHP.

PHP is a scripting language designed for creating web-based applications. It's also commonly used with MySQL, a database management system that accepts commands in a database language called SQL. PHP and MySQL are typically configured to run with a web server, most commonly the Apache web server. Apache, PHP, and MySQL are all free.

Now, onto the useful stuff:

First, we will setup a web server, on your computer, with PHP and MySQL using XAMPP. (Don't worry, this is absolutely painless!) Next, we will test to see if things are working by writing your first PHP script. I'll conclude by giving you an overview of your possible next steps.

Getting a Web Server Up and Running Using XAMPP.

If you use Windows, getting an Apache web server installed with PHP and MySQL support is as easy as downloading and installing XAMPP. Just click the download link and open the installer file. The rest you know already. ;)

(Even better: XAMPP is also supported for Linux, Solaris, and Mac. But, I'm assuming you're using Microsoft Windows for the duration of this tutorial. As long as you know how to change folders and rename files in your non-Windows operating system, you can follow along even if you're not using Windows.)

Your First PHP Script

Now that we have everything up and running, let's find out how to use it.

It's a common tradition amongst programmer's to start out one's first program in a new language with a "Hello World" application. The script simply displays "Hello World" with no user input. Let's try doing that!

  1. Open up Notepad or any plaintext editing software, and type in:

  2. Now, save the file as hellow in C:/Program Files/XAMPP/htdocs. (I'm assuming you installed XAMPP in its default directory. If you installed it elsewhere, point it to the htdocs folder in wherever you installed XAMPP to.)
  3. If the file is saved as a text file with extension .txt, we'll have to rename it to .php. If you don't know how to rename files, here's one way to do it. If you use Windows:
  4. Fire up your favorite browser and load this address: http://localhost/hellow.php
  5. And you're done!

Next Steps

So you now have a web server up and running with PHP support on your computer. But, you haven't quite made the neato server-side application you wanted to make. You can find tutorials all over the web on this stuff, or if you like learning from me, you can go onto my next tutorials to learn more about what you can do with PHP and MySQL.