Americas

  • United States

The Zen of PHP

Opinion
Mar 10, 20034 mins
Enterprise ApplicationsPHP

In a nutshell, PHP is primarily a server-side scripting language (it also can be used client-side) that is used in much the same way as ASP. But PHP has been around since 1994, and according to the Netcraft survey of technology in use on the Web, more than 6 million domains use PHP scripting and that number is growing at 15% per month.

We’ve always loved those smart-alecky names that programmers give to their applications. In particular, we rejoice in the recursive names such as Pine and PHP. Pine used to be one of the most widely used e-mail packages for Unix and came after another e-mail program called Elm. PINE is a recursive acronym that stands for “Pine Is Not Elm” (yes, you have to be a geek to find this stuff funny).

PHP, which incidentally is our topic for this week, is also a recursive acronym that stands for “PHP: Hypertext Processor.” Not quite as clever as Pine but not bad.

The topic of PHP came up when some of you wrote in after the series of columns we did on Active Server Pages  (ASP). What you wrote was along the lines of, “We couldn’t care less about ASP ’cause PHP rules, so why don’t you write about PHP unless you want us to come around and rough you up.” So we proudly present PHP!

In a nutshell, PHP is primarily a server-side scripting language (it also can be used client-side) that is used in much the same way as ASP. But PHP has been around since 1994, and according to the Netcraft survey of technology in use on the Web, more than 6 million domains use PHP scripting and that number is growing at 15% per month (see www.php.net/usage.php).

PHP is a project run under the auspices of the Apache Software Foundation and the scripting engine – the PHP interpreter, called the Zend Engine – was developed and is published by Zend Technologies.

The Zend Engine is open source, cross-platform and free! It runs on all flavors of Unix and Linux, Windows 98, ME, 2000, NT and XP, AmigaOS, Mac OS X, Novell NetWare, OS/2, RISC OS, SGI IRIX 6.5.x and AS/400.

So what makes PHP so popular? Well, other than being free, open source and cross-platform, we also suspect that being non-Microsoft attracts a lot of people. Even so, the really big advantages are that PHP allows for elegant coding and offers great performance. And PHP is also fairly easy to learn for even novice programmers – it has syntax similar to that of C or Perl.

PHP is also versatile – it supports HTTP sessions, Java connectivity, regular expressions and a full alphabet soup of protocols, including LDAP, SNMP, IMAP and, under Windows, COM. PHP also supports a relatively new, very cool and definitely groovy XML-based data exchange standard called WDDX , which we will discuss in a future column.

As for Web server support, PHP supports ISAPI or, as an alternative, a direct module interface called SAPI, which offers better performance and is compatible with Apache, Microsoft Internet Information Server, Netscape and iPlanet servers. You also can use PHP as a CGI processor, which requires the command-line executable version of PHP.

With PHP you are not limited to outputting HTML – you also can output images, PDF files, Flash movies, XHTML content and, obviously, any XML content. There are all sorts of libraries to make these formats easy to create.

If you are committed to PHP programming you can create client-side GUI applications using something called the PHP-GTK, a cross-platform windowing library.

Another major strength of PHP lies in its database support – writing database applications using PHP is simpler than in many other languages. PHP supports Adabas D, Ingres, Oracle (OCI7 and OCI8), dBase, InterBase, Ovrimos, Empress, FrontBase, PostgreSQL, FilePro (read-only), mSQL, Solid, Hyperwave, Direct MS-SQL, Sybase, IBM DB2, MySQL, Velocis, Informix, ODBC and Unix dbm (whew!).

Installing PHP is pretty easy – click  for general instructions and detailed instructions for specific operating systems.

Once installed, there are a number of run time configuration options that are stored in the php.ini file. The location of this file depends on the operating system and any specific options compiled into the executable – see here .

So by now you must be wondering what a Web page with a PHP script looks like. Here’s the standard “Hello world” script in PHP:

    

        

PHP Test

    

    

         

    

No surprises there, eh? Next week, we’ll delve deeper.

Deep thoughts to gearhead@gibbs.com.

mark_gibbs

Mark Gibbs is an author, journalist, and man of mystery. His writing for Network World is widely considered to be vastly underpaid. For more than 30 years, Gibbs has consulted, lectured, and authored numerous articles and books about networking, information technology, and the social and political issues surrounding them. His complete bio can be found at http://gibbs.com/mgbio

More from this author