Web Server Programming

Chapter 6
PHP

Getting PHP

You can download your PHP from the PHP home site. I have not included direct links to the downloads; the PHP site is mirrored and you should download from the mirror that is closest to you - the links to the mirror sites are on the download page at php.net. (As noted in the section on Apache, you can download a bundle with Apache, PHP, and MySQL for Windows from Hotscripts.) You will of course need the PHP documentation. This is available in many languages, with on-line and downloadable versions. Currently, only HTML documentation is available (the older PDF manual is "out of print"). It is likely that the documentation will eventually all be in the form of XML documents with alternative XSL programs for generating both HTML and PDF versions; so you may find that a PDF version is again available soon.

Cygwin and Linux users probably have a version of PHP included in their releases (maybe not the most up to date version but one that should be adequate for learning exercises). Although on the system, these PHPs are most likely not integrated into the Apache that is also installed. There are instructions for Unix/Linux (and Windows) at the PHP site. alternative explanations are at the PHP tutorial site associated with O'Reilly publishers, and in the tutorials at the Site Wizard. (You may find configuring your PHP-Apache the hardest part of using PHP.) A Cygwin system most likely includes a PHP component in a subdirectory of the /release directory; this contains a precompiled .dll and a shell script that has to be run to complete installation. Essentially, you have to copy the PHP .dll into the library subdirectory used by Apache and then "rebase" your .dlls. The Apache httpd.conf configuration file must also be updated.

The following instructions will give you a working PHP with Windows and Apache. These instructions do NOT define the way to fully configure a PHP-Apache combination that allows safe and correct operation on the Internet. They represent a quick hack that lets you get started quickly running your own Windows-Apache, and accessing it via a browser aimed at localhost.

Read and follow the instructions that come with the download, or any of the web sites noted above, to complete a proper installation.

Extensions

Your PHP download should include the available extensions in its "extensions" folder. It you need anything, e.g. a different database connection, then simply copy the necessary module to your extensions_dir directory and edit your php.ini file.

On line resources

Along with the downloads, and documentation, the main PHP.net site has current news about PHP. Topics include surveys of usage, and details of various PHP courses and conferences that are to be offered world wide. Other moves to commercialize PHP are reported at the Zend site.

The on line code and tutorial resources for PHP are not yet as comprehensive as those of Perl but there is a growing body of material available. Naturally, there are PHP sections at both Yahoo and Google.

News articles, commentary, tutorials, example code, and components (e.g. shopping carts etc) are available at a number of sites including:

Amazon has something like 90 PHP related books including many that focus on specific issues such as use of PHP and MySQL. There is even a PHP-5 title listed (though not yet available).

Example materials relating to the text

A few of the examples from the text are available.