PHP Basics

Giles Orr

12 September, 2000

PHP (a recursive acronym for "PHP: Hypertext Preprocessor") is a widely used server-side, cross platform, HTML embedded scripting language. Because it's processed on the server, you don't need to worry if your client-side Java or Javascript will be run. Because it's fast, you can use it without bringing your server to its knees.


Table of Contents
Introduction
Available Versions
Apache Web Server Configuration
Making Sure PHP is Running
Basics
Variables
Control Structures
Comments
Forms Handling Example
Conclusion
Resources

Introduction

PHP is a recursive acronym for "PHP: Hypertext Preprocessor." This is in the GNU software tradition of using recursive names. GNU itself stands for "GNU's Not Unix!" GNU is a project started in 1984 by Richard Stallman at M.I.T. to develop a Unix-like operating system for free. In the process of doing this, they developed a software licence for their programs called the "GNU Public Licence," commonly called "the GPL." Linux is based heavily on GNU software, and most Linux software, whether it is considered a part of the GNU project or not, is placed under the GPL. PHP is under a licence similar to the GPL, and still free.

PHP is a programming language which is embedded in HTML. When a PHP file is requested from the web server, the PHP preprocessor is invoked, scans the file for PHP tags, and processes the code inside those tags. The web server identifies file types by file extension. HTML is sent out unmodified. What follows is the basics of the PHP language.

When learning PHP, you will need at least minimal programming skills. I have in the past attempted to master C, Perl, and shell scripting. I'm not good at C and Perl, I'm passable at shell scripting. To me, PHP is a lot like C without the parts I hated (like pointers), and with the addition of some stuff I like (like regular expressions). If you understand the basic concepts of programming, such as variables, if-else, and looping, PHP is a breeze. Using their online manual, which I cannot praise enough, I was writing working PHP code inside of two hours, and I'm not exactly a master programmer.