Datasheet

8
Part I PHP: The Basics
are allowed to charge money for guaranteeing that every copy of the software you distribute
will be virus-free or of reasonable quality, taking on the risk of being sued if a bunch of cus-
tomers get bad CD-ROMs that contain hard-drive-erasing viruses.
Usually, open source software users can freely choose the precisely optimal cost-benefit
equation for each particular situation: no cost and no warranties, or expensive but well sup-
ported, or something in between. No organized attempt has been made yet to sell service and
support for PHP (although presumably that will be one of the value-adds of Zend). MySQL AB
does sell support as part some of its licensing packages for the MySQL product. Other open
source products, such as Linux, have companies such as Red Hat standing by to answer your
questions, but the commercialization process is still in the early stages for PHP.
Ease of Use
PHP is easy to learn, compared to the other ways to achieve similar functionality. Unlike Java
Server Pages or C-based CGI, PHP doesn’t require you to gain a deep understanding of a
major programming language before you can make a trivial database or remote-server call.
Unlike Perl, which has been semijokingly called a “write-only language,” PHP has a syntax
that is quite easy to parse and human-friendly. And unlike ASP.NET, PHP is stable and ready
to solve your problems today.
Many of the most useful specific functions (such as those for opening a connection to an
Oracle database or fetching e-mail from an IMAP server) are predefined for you. A lot of
complete scripts are waiting out there for you to look at as you’re learning PHP. In fact, it’s
entirely possible to use PHP just by modifying freely available scripts rather than starting
from scratch you’ll still need to understand the basic principles, but you can avoid many
frustrating and time-consuming minor mistakes.
We must mention one caveat: Easy means different things to different people, and for some
Web developers it has come to connote a graphical, drag-and-drop, What You See Is What You
Get development environment. To become truly proficient at PHP, you need to be comfort-
able editing HTML by hand. You can use WYSIWYG editors to design sites, format pages, and
insert client-side features before you add PHP functionality to the source code. There are
even ways, which we’ll detail in Chapter 3, to add PHP functions to your favorite editing envi-
ronment. It’s not realistic, however, to think you can take full advantage of PHP’s capabilities
without ever looking at source code.
Most advanced PHP users (including most of the development team members) are diehard
hand-coders. They tend to share certain gut-level, subcultural assumptions for instance,
that hand-written code is beautiful and clean and maximally browser-compatible and there-
fore the only way to go that they do not hesitate to express in vigorous terms. The PHP
community offers help and trades tips mostly by e-mail, and if you want to participate, you
have to be able to parse plain-text source code with facility. Some WYSIWYG users occasion-
ally ask list members to diagnose their problems by looking at their Web pages instead of
their source code, but this rarely ends well.
That said, let us reiterate that PHP really is easy to learn and write, especially for those with
a little bit of experience in a C-syntaxed programming language. It’s just a little more involved
than HTML but probably simpler than JavaScript and definitely less conceptually complex
than JSP or ASP.NET.
03 557467 ch01.qxd 4/5/04 11:06 AM Page 8