#native_company# #native_desc#
#native_cta#

The ABC’s of PHP: Introduction to PHP Page 2

By Peter Shaw
on February 26, 2009

Ok, we know about you, what about PHP?
PHP was originally a pet project written circa 1994 by Rasmus Lerdorf as a way for him to count how many people where viewing his web-based on-line CV. Rasmus released the first public version sometime in 1995 where he had an interested following in the open source community that assisted him in improving and fixing bugs in the system.
By mid to late 1995, Rasmus had added a web forms interpreter and MySql library code to his project to accommodate the growing need for storage and processing of data received in HTML forms. This proved that there was a need for a system that could handle this kind of task and Rasmus released the next version now called “PHP/FI” which stood for ‘Personal Home Pages Forms Interpreter’. The open source project went from front to back and by 1997 Zeev Suraski and Andi Gutmans had joined the team. They then did a major rewrite of the main core, to form the basis of PHP3. The project was subsequently renamed “PHP Hypertext Pre-Processor”, and went on to become the current PHP versions we know today.
So how does PHP Work?
PHP in itself is a very simple system. It works very much like Java does in terms of byte code, but rather than compile once and deploy, the PHP interpreter compiles each time the script or code is run.
Essentially PHP is an interpreted language much like bash shell programming, but it is also a compiled language much like C or C++. This means that the language is both extremely portable, yet it is also very fast to execute.
The best thing about PHP however, is not how the PHP engine compiles it, but how it’s actually employed in the world of HTML and web pages. PHP code can be integrated directly into your HTML–all it takes is for the file extension to be renamed to .php and the code to be enclosed in PHP tags as follows:

<html>
  <head>
    <title>My Page</title>
  </head>
  <body>
  <?php
  
    Print "<h1>Hello World</h1>";

  ?>
  </body>
</head>

When saved to a web server and run, the output will show a regular HTML page, with a heading 1 size element that says “Hello World” and a page title of “My Page”. The first thing you’ll notice if you view the page source is that the PHP code has vanished and that the output is plain HTML. This is a very important concept to remember.
Most languages have to have some form of output where the results can be displayed. For Microsoft Windows and most modern versions of Linux these days, this is the Desktop GUI environment with its point and click interface. For those of you (like me) who are command-line junkies, this will be a standard Console output usually in your default terminal colours.
In the web environment, PHP’s output is via your browser’s display. This means that there are some things that are not fully possible, but it also means that some very eye catching and colourful displays can be produced by combining nice graphics and good CSS concepts.
Summary
As you can see, PHP has a good track record and has the capability to make standard web pages come alive. In the next article in this series, we’ll look at what you need to start developing in PHP and how to set it up both under Linux and Windows.
Until next time, remember, programming is not about following text books, it’s about experimentation and frustration. Above all however, it’s about having fun while learning something new along the way.
If you have any comments or ideas on this series, please don’t hesitate to make them known via the comment form below and I’ll see what I can do to accommodate them!
All the best.
Shawty