Understanding PHP
PHP is an open source
server side scripting
P
HP, the PHP Hypertext Processor, is an open source server side scripting
language for Web servers, which provides a real alternative to ASP, Cold 
Fusion, Mod_Perl or JSP if your aim is to provide dynamic Web pages.
Dynamic Web pages are pages which interact with the user, so that each user
language, which can be
visiting the page sees customized information   which may vary each time and
embedded inside HTML
which may be based on a form they've just filled in, or on information extracted
from a database or some other external source. Typical applications include
as a clever means of
e commerce, online newspapers, visitors' books, ticketing systems, project man 
agement, and other groupware projects. The traditional way to produce this type
providing dynamic Web
of dynamic page is via CGI scripts, but these are separate programs which must
pages. C and Perl
be executed as a new process for each page hit, so they scale badly and rapidly
become memory and processor hogs as server load increases.
developers will find it
PHP solves this problem by becoming a part of the Web server, essentially
particularly intuitive to
extending the functionality of the server itself, so that the server can do the
learn.
processing without having to spawn extra processes. It's not alone in doing this,
but unlike most other scripting languages for Web page development PHP also
offers excellent connectivity to most of the databases in use today. Perhaps the
By Paul Oldham
greatest advantage of PHP, when compared to other scripting languages such as
Technical Consultant
ASP or ColdFusion, is that it is open source and cross platform. PHP's natural
home is on Linux servers running Apache server software, but it runs equally
well on any other Unix or Windows platform, and can be used with other Web
servers.
PHP started life as a Perl program written by Rasmus Lerdorf to track visitors to
his online resume. It was then rewritten in C and was extended to include support
for database access. From these simple beginnings the open source community
has expanded and developed PHP into a powerful server side scripting language.
Which Version?
An earlier version of PHP that was released publicly was called PHP/FI 2.0, and
you may still find this on some ISPs' servers and Linux distributions, but it wasn't
until PHP3 that the language really came into its own. PHP3 has been around
since June 1998 and is still the most widely used release. However, we are
currently in a transition period, as PHP4 came out of beta in May this year. PHP4
uses a new engine called Zend and offers greatly improved performance and
increased functionality, so we can expect developers and ISPs to start migrating
to that release soon. Code written in PHP3 is compatible with the PHP4 engine
with a few minor exceptions, and in this article we'll consider both releases,
highlighting any differences as we go.
In July 2000 Netcraft's ongoing survey of Web servers reported that 3,121,918
domains at 598,213 IP addresses had PHP available on their Web server. Of
course, such wide availability doesn't mean it has actually been used on all those
servers, but organisations such as Mitsubishi, Redhat, livebid.amazon.com, Der
Spiegel, MP3 Lycos, Ericsson, Sprint Canada, xoom.com and NASA are all ac 
tively using PHP today.
Writing PHP
What sets PHP apart from its origins in Perl is the ability to embed PHP code
inside HTML, allowing you to mix HTML and PHP in one source file rather than
having to crank out the HTML from within Perl. For example, a simple PHP script
to show today's date is shown in Figure 1. If you're familiar with HTML then the
top and bottom of this code will look very familiar   it's just standard HTML. The
Issue 125:December 2000
PC Network Advisor
File: T1837.1
page 13
Tutorial:Internet
www.itp journals.com
Next page  >
New! The best sites for quality inkjet printer cartridges and the best sites for cheap inkjet cartridges
Windows Help Desk Home