PHP: Babysteps Tutorial

What is PHP?

PHP is a server-side scripting language for creating dynamic Web pages. It has a very elegant design, that is both easy to use and powerful. PHP stands for PHP: Hypertext Preprocessor. It is a server side, HTML embedded language like ASP, SSI etc.

In simple words - PHP sits on a web server, handles all the code and presents the final output in HTML format to the browser.

<html>
<body>

   <?php
      echo ("test");
   ?>
</body>
</html>

The above code demonstrates the usage of PHP. You might have noticed a similarity to Javascript. But one BIG difference is that PHP runs on the server and Javascript runs on the client. That makes PHP very powerful!

So why use it?

Haven't you atleast once thought that plain HTML sucks? Haven't you dearly wanted to create a counter for your site? Aren't you tired of using frames and wished there was an 'include' command in HTML? Haven't you pulled your hair while trying to do any file system operations with HTML? If you have, then PHP is the answer for you! It has the power to convert your drab, "just another website" into a real jazzy one (like sig9 off course ;). Counters, guestbooks, message boards, online polls, search engines... anything is possible with PHP!

Learning PHP

PHP amazingly with all its power is quite simple to learn, especially if you have some background in languages like C++. The syntax is quite similar, with a lot of interesting and some times wierd syntax.. and loads of built-in functions! I myself first thought that PHP was a tough nut to crack, but once I got into it, it was like a knife into butter.

So how to do it? Follow these steps. I think this is the shortest practical way to glory.

  1. Download PHP package for your o/s from www.php.net
  2. Download PHP manual from www.php.net
  3. Download a simple webserver [ www.badblue.com for Windows, Apache.org for Linux/Windows ].
  4. Set up the webserver and PHP on your PC, using instructions from BadBlue (or Apache) and PHP sites
  5. Download a few simple PHP scripts from sites like www.hotscripts.com
  6. Read the manual, put PHP on test, do some code sneaking and finally try to create some PHP magic!
If you are a Windows user, then I would recommend using BadBlue while you are learning, for the simple reason that it is so easy to install. You might (almost certainly) have to switch to Apache in the long run though. Also Windows XPNT users with IIS can configure that to run PHP too. Instructions are available at the PHP site.

That's it folks. I hope you have managed to take your first steps in learning PHP. If not, be a wimp and go learn Pearl! :)