If you don't know about this promising language for Web development, you should.
PHP
is a flexible, portable Web-programming language that began as someone's
personal project. It has come far. As of April 2006, over 20 million public domains (to say
nothing of intranets and other private sites) were using PHP. IBM and Oracle
endorse it. Where does PHP fit in a professional IT organization?
PHP Basics
PHP, officially named "PHP: Hypertext Preprocessor,"
is a general-purpose dynamic language. Designed for server-side Web development,
it typically outputs ordinary HTML, viewable in any Web browser. PHP runs on
most major operating systems, including UNIX (with variants such as Linux),
Windows, and Mac OS X.
Carlos Recalde,
Managing Director of New York City–based Successful Technology, LLC, helps
corporate executives align business strategy with technical direction:
"coordinating the CEO's vision with the CIO's vision," he says. Recalde also
volunteers his talents for nonprofit groups, where PHP is often recommended for
its flexibility and its support of many environments and platforms. Programmers
of varied backgrounds can usually understand and modify PHP applications.
Recalde emphasizes that downloadable, fully functional, PHP-based open-source
applications can address the needs of nonprofits quickly and
inexpensively.
PHP has always been primarily a Web programming language
with goals of simplicity and clear syntax. Rasmus Lerdorf created
the first version of PHP in 1995 to help him track online hits to his
résumé. At first, PHP stood for Personal Home Page (Tools). In
1997, Israeli university students Andi Gutmans and Zeev Suraski (who together
later formed Zend) began to make PHP a
structurally sound language for future growth. PHP continues to evolve at a
rapid pace. An
Introduction to PHP, excerpted from Core PHP Programming, Third Edition
(2003), by Leon Atkinson and Zeev Suraski, provides a lively, detailed
history.
PHP, which has an open-source license, is not owned by
any commercial entity. Hundreds of programmers worldwide, working either pro
bono or for their employers, contribute improvements and bug fixes. Yahoo!
engineer Andrei
Zmievski has been enhancing PHP's internationalization support, especially
Unicode, on Yahoo!'s behalf. The improvements will appear in PHP Version 6
(release date unannounced), providing a stronger language for both Yahoo! and
the broader PHP community. (Zmievski is scheduled to discuss PHP 6 and Unicode
on June 16, 2006, at the New York PHP
Conference.) The widely dispersed development efforts are coordinated by
Zend. (Aron Trauring's "Free
and Open Source Software: A Field Guide" provides a thorough explanation of
the open-source movement and its business model.)
PHP programs are
typically stored in text files with the extension .php. As part of PHP's Web
heritage, commands are often combined with HTML, especially in simple programs.
The following example, try.php, was created with a text editor. (I used EditPad Pro, but Windows Notepad is also
fine.) Programs written in PHP are interpreted, not statically compiled. As a
result, the output appears as soon as the browser window is
refreshed.
Try.php looks like
this:
Try
a simple PHP program
The
simple output of try.php is shown in Figure 1.
Figure 1: Simple HTML output is produced by try.php. (Click images to
enlarge.)
The
example above shows how PHP tags can commingle with HTML in simple programs.
More sophisticated programs use a template engine or framework
to separate HTML from programming logic.
Support for Popular Databases
Although PHP supports many relational database
management systems, the database most closely associated with PHP is MySql. MySql is supported by most hosting
services that support PHP. Even though a commercial entity, MySQL AB, owns the
source code, MySql is free open-source software. For a fee, MySql AB provides
support and enterprise-ready, scaled-up versions of the database.
Besides MySql, PHP supports most popular databases, including Oracle,
IBM DB2, and Microsoft SQL Server. Some database vendors, such as Oracle and
IBM, contribute code to help PHP work with their products
efficiently.
Sample code below reads DB2 data from an IBM System i
server. Note the and
?> tags that start and end a block
of PHP code. The rest is
HTML.
Show System i/DB2 Data Countertop Codes Starting with
'A'
Countertop
Code | Short
Description |
Long
Description |
|---|
$dbname="SYSTEMA"; $dbuser="usera"; $dbpwd="slate";
//
connect to database with user and
password $db=odbc_connect($dbname,$dbuser,$dbpwd);
//
select codes starting with
'A' $sql="select cocd, codess,
codesc from prodlib.counter where cocd like
'A%'"; $result=odbc_exec($db,$sql);
//
loop through, embedding field values in HTML table cell
tags While (odbc_fetch_row($result))
{
printf("| %s | %s |
%s | ", odbc_result($result,1),odbc_result($result,2),odbc_result($result,3));
}
odbc_close($db); ?>
The
HTML result is shown in Figure 2.
Figure 2: PHP displays System i/DB2 data formatted with HTML.
Free and Open-Source Software Packages Built with PHP
Carlos Recalde of Successful Technology notes the
large number of downloadable software packages built with PHP that are available
for free or at low cost. Collaborative and content-management software in
particular is plentiful and varied. Popular,
high-quality packages, all free, include these:
* A wiki is a collaborative Web site that can be edited using a Web
browser.
Open-source packages such as those listed above offer many
advantages:
- These high-quality packages are frequently updated.
- If the
package isn't exactly what you want, you can modify it.
- If the documentation
does not answer your questions, you can look at the source code for more insight
into the workings of the package.
- Many packages are backed by strong online communities that offer help and
software enhancements.
- Programmers can study the source code to
learn professional PHP techniques.
Case Study: Rapid, Inexpensive Web Development
Randall Rode, IT Director at the Yale School of Drama/Yale Repertory Theatre, discovered PHP in
2004, he explained in a telephone interview. Intrigued by the ability of
blogging software to manage Web content, Rode started his own blog, RodeWorks. He created his blog with free
PHP-based software from WordPress that he
installed on a low-cost Web
host.
Rode, who considers himself not so much a programmer as "a
generalist who solves problems with IT," studied the WordPress software and
modified its PHP code to his liking. Finding PHP easy to use, he wanted to learn
more. At a two-day "PHP for Designers"
course in New York City, Rode saw that the language could help with projects
at Yale.
The dean at the drama school had requested two Web-based
applications: a subscription-purchase system for the Yale theater's public
(deadline: September 2005) and a course-evaluation system for students
(deadline: late fall 2005). Rode's deadlines and tight budget limited his access
to outside help.
Rode wondered whether he could use PHP and a MySql
database to handle such projects himself. He created prototype applications on
his hosted server that showed he could. He then tackled the full systems..
Working through summer 2005, he reached his goal, finishing in time for the new
season. The theater started to sell subscriptions online in September 2005 (http://yalerep.com/buy_subs.html).
Students evaluated their courses online by semester’s end. Rode's hard
work paid off.
PHP in the Enterprise
Despite PHP's popularity, it has not displaced the
traditional enterprise and large-scale frameworks such as Microsoft .NET and
Java's J2EE. Can PHP support the weight of a complex enterprise
architecture?
Although PHP is great for "islands"—small departments
or specific, individual needs—it's not designed to produce a
well-integrated enterprise architecture, according to Recalde. For example, an
attempt to use PHP to distribute a load-balanced application dynamically over 12
data centers across the globe, while possible, would have to be "cobbled
together," requiring extra layers of resources and management effort. Although
.NET and J2EE are more complex than PHP, Recalde points out, their complexity
allows them to fit more efficiently into a global enterprise
architecture.
(The Professional
PHP blog assesses PHP's strengths and weaknesses for enterprise
use.)
Some are working to make PHP more attractive to the enterprise
market. Zend has created a package called Zend
Platform to make PHP applications "enterprise grade."
Zend Platform
combines the Zend Performance Suite with PHP Intelligence, PHP Configuration
Control, and the PHP/Java Interoperability Bridge. These features are intended
to provide "the reliability, scalability and interoperability required for
business critical applications," Zend states.
J2EE and PHP sometimes work
together. A flexible PHP front-end layer can communicate with a J2EE back-end
system. One rationale for introducing PHP into a J2EE system, besides PHP's
productivity for Web programming, is that many industry participants believe PHP
developers charge less, on average, than Java developers of equal skill.
Two articles posted on the IBM Web site show different ways to combine
PHP with J2EE:
Another way to join PHP with Java comes from the Zend
Platform PHP/Java
Integration Bridge.
According to the Zend PHP/Java
Integration Bridge Web page, the Bridge "is based on a unique design that
allows for a single Java Virtual Machine (JVM) instantiation and direct calls
from PHP. [It] allows companies who have investments in J2EE application servers
to take advantage of PHP, the high-productivity language for Web application
development. In addition, the Integration Bridge allows companies using PHP to
take advantage of J2EE services that are not present in PHP. The Zend Platform
PHP/Java Integration Bridge provides the ability for PHP developers to create
applications that interact with any Java object."
IT Industry Leaders Endorse PHP
Commercial entities are advocating open-source
technology. In a move comparable to IBM's groundbreaking adoption of Linux
several years ago, IBM has been devoting resources and publicity to PHP. Here's
a rough timeline:
- IBM used PHP internally for several years before
touting it publicly.
- Independent user groups are treated generously. For
example, since June 2004, New York PHP's
monthly meetings have been welcomed at IBM's landmark offices at 590 Madison
Avenue.
- In February 2005, Zend and IBM jointly announced Zend Core for
IBM, a packaged, supported PHP distribution, with optimized interfaces for
IBM's Cloudscape and DB2 databases.
- Engineers have stocked IBM's Web site with numerous technical PHP articles,
such as the outstanding PHP
reading list compiled by Daniel Krook and Carlos Hoyos.
- IBM has been sending its experts to user-group meetings to promote the
capabilities of PHP.
- In March 2006, Zend released an early version of Zend Core for
i5/OS (System i), which, over time, will be enhanced to support unique
System i features.
- Oracle has devoted resources to PHP development, creating a PHP Developer
Center.
- Oracle has partnered with Zend to create an Oracle-optimized
version of Zend Core.
The IT community monitors the
strategy of IBM and other big players. The significance of IBM's interest in
open-source technology was stressed by a longtime industry observer, Aron
Trauring. In May 2005, Trauring, CEO of Zoteca, told the New York Software Industry
Association's Open Source group, which he chairs, "IBM is the IT
industry." (Trauring wrote the paper on open-source software cited earlier in
this article.)
Try It
It's easy to try PHP on a server or personal
computer. Download XAMPP, a free package that
includes PHP, MySql, and the Apache Web server. Scroll down the distribution
list till you see the version appropriate for your operating system.
If
your IT environment does not support PHP directly or cannot spare a server,
Randall Rode's method may work for you. Run a pilot project using an inexpensive
(often less than $10/month) hosted server that supports PHP. Upload your PHP
files to the server via FTP or other file-upload facility. Type the appropriate
URL into a browser address bar. You are now running PHP.
Resources
General • PHP home page and online documentation • php tutorial • Making the
Case for PHP at Yahoo! • Latest PHP usage
statistics • Wikipedia
entry for PHP • IBM's
recommended PHP reading list • IBM's
PHP project resources
IBM System i/i5 • i5php.net (community forum) • Zend Core
for i5/OS
• IBM System
i and Zend PHP
Events • PHP events around the world • New York PHP Conference
Email
Lists • php.net
lists • nyphp.org
lists
Publications • PHP
Architect • PHP
Magazine
Alan Seiden is a consultant and developer at a northern New Jersey IT firm, where he enjoys
helping clients to meet business goals through the creative use of technology.
Alan is vice president of the New York City
Usability Professionals Association. Email Alan at
This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
. |