Thursday, November 8, 2007

Getting Started With PHP and MySQL in Windows with EasyPHP


I'm sure you have all heart one time or another about this cool stuff called "PHP" and MySQL, and some of you have probably heart that you need Linux to use this stuff.
Well that's not true. Of course, Linux is the best operating system for hosting a website, but Linux is not ideal way for a newbie to learn PHP.
All you need for your first steps in PHP and MySQL is a cool program called EasyPHP (Free here). Basically this is a collection of programs.
More Specific,

  • Apache the web server, the program that is responsible for viewing you sites and working together with PHP.
  • PHP Module For Apache
  • MySQL Database Server

All you have to do is download install and run the program. I recommend using the default Directory C:\Program Files\EasyPHP1-8 so that you will follow the tutorials easily.
After installation completes goto Start - Programs - EasyPHP - EasyPHP.exe
You should see an icon in your taskbar, double click on it. you should see something like this:

This is a question, if you want to update the program. Just click OK.

Then double click on the "e" on the taskbar. You should see this window:
If the little dots beside the Apache Button and MySQL button are Green, that means that you are ok, and ready to go!

Your First PHP Program

To test this open your favourite browser (Or Internet Explorer :p) and write

You should see something like this:
You are ready to start PHP Programming. the location for the files is C:\Program Files\EasyPHP1-8\www or something like this (where you have installed EasyPHP)
Go in that folder. you should see a file "index.php". Open it. You can use notepad, WordPad or any editor you want. I use Notepad++ and PHP Expert Editor. Whatever makes you feel better.
When you open the file, you see a mixture of HTML and PHP.
All PHP code is in the php tags. That is <?php and ?>
For example, a hello world program:

echo "Hello World !!!";

Create a new file, for example index2.php and write the code above and save it. Then open with your browser
You should see this:

To check some PHP functions and view some interesting information about you system, write this into file under hello world example:

<?php phpinfo( ); ?>

You should see this:

That's all for now. The next example will be an introduction of the MySQL basics and a simple MySQL example.

No comments: