19
Fri, Apr
5 New Articles

PHP: A Party Waiting for a Few Good Developers

Web Languages
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

PHP was created in 1995 by Rasmus Lerdoff, a 38-year-old from Greenland. Zeev Suraski and Andi Gutmans later worked with him to create PHP 3. Eventually, Zeev and Andi formed Zend Technologies, the name being a combination of letters from their first names.

Zend is responsible for bringing PHP to the System i. The company claims that PHP is "the most widely used programming language on the Web." The usage statistics for PHP, compiled by Netcraft, show that it is in use on over 20 million domains at more than 1.2 million IP addresses. And those are just the publicly visible domains. It is probable that it is also in broad use on private intranets. With these numbers in mind, it's no wonder an IBM representative recently told me, "We feel like we are just joining a party that everyone else was invited to long ago." He was referring to the recent development of PHP now being available on the System i.

What Is PHP?

PHP stands for PHP:Hypertext Preprocessor, an acronym that actually is a private joke shared among the "in crowd," because it's a recursive acronym; PHP is in the definition of PHP itself. I suppose this reflects its geeky origins, which are both its strength and its weakness.

PHP is actually several different things rolled into one. It is a formal language specification, an implementation of that specification, and a Web server plug-in (or Apache module). On the iSeries, the Apache module is supplied by Zend. The table below demonstrates how you might compare it to two other popular Web implementations on the System i.

Popular Web Implementations

PHP CGI Java
Web Server Apache Apache WebSphere
Protocol PHP License CGI Java
Middleware Zend Core CGI Extension WebSphere WAS
Language Environment Apache Module I5/OS (usually ILE objects) Java Virtual Machine


PHP is open source, and the typical license is free (although there are restrictions on its redistribution). As such, it is part of a commonly used open-source development and deployment environment that is often referred to by the acronym "LAMP," meaning Linux-Apache-MySQL-PHP.

Other than the hardware, the following are all the components necessary to run a dynamic, database-driven Web site: Linux for the operating system, Apache as the Web server, MySQL for the database engine, and PHP as the Web language. On the System i, you might refer to it as SAMP, if you substitute "System i" for "Linux," although this is not nearly so clever-sounding as LAMP. Note that PHP is an alternative method to delivering Web pages via CGI or Java, so you don't program PHP with CGI or CGIDEV2, Net.Data, or JavaServer Pages (JSP). You can, however, mix and match technologies when you deploy your Web site. So PHP programs can link to CGI programs and vice versa.

PHP is a hybrid scripting/compiled language. Like Visual Basic, PHP is generally interpreted as it is executed. This means the code is parsed and syntax-checked on the fly, as Web-page requests are made. Critics of this approach claim that the interpretive nature of PHP results in performance issues, compared with using compiled programs such as RPG CGI programs. However, Zend also provides a caching mechanism that will store previously executed code in a pseudo-compiled mode, which helps performance.

In any Web application, database access code can have a significant impact on performance. For example, if an SQL statement uses a complex join that requires building an entire access path from scratch every time, that is likely to have much more impact on performance than the fact that the PHP code itself is interpreted.

Wikipedia describes PHP as an imperative, object-oriented, functional language. This means you can write it when using procedural programming techniques (as you would in RPG or COBOL) or when using object-oriented techniques (as you would in Java, C++, or other object-oriented languages). The object-oriented features are a relatively new addition, not included until PHP 5 was released in July 2004.

How Programs Are Structured with PHP

PHP uses a similar program structure to that of other Web languages/tools such as ASP (Microsoft's approach), ColdFusion, or JSP. This generally involves interleaving server-side code with your presentation code (HTML and CSS). You often need to do this in order to include database values or other computed variables in the page output, in addition to any static HTML. You can include bigger chunks of HTML by referencing separate source files within your PHP source file, but often programmers simply start outputting content whenever they need to. This is quite a different approach to programming compared with interactive green-screen RPG programming, in which content (Display File DDS) is completely separated from logic (RPG workstation programs).

It doesn't take much to get used to this approach, and if you have already programmed in one of the other languages mentioned above, you'll be completely familiar with this notion. However, one of the drawbacks to this programming style is that it can make it difficult for you, or other developers, to read the programming logic because it is often intertwined with the presentation markup. Also, it can result in poorly designed and structured code that is ad hoc in nature.

This is both the blessing and the curse of PHP; it's extremely easy to start writing in it, but it's also easy to write bad code. For this reason, it's a good idea to invest time up front in developing programming protocols for developers to abide by that result in well-structured and organized code. For instance, one should consider encapsulating common routines, such as authentication and login routines, in separate source files.

The Open-Source Community

Because PHP is open source, there is a vast array of resources available on the Web for helping you learn PHP, write applications, or download open-source applications already written. For instance, a simple Google search for "PHP examples" yields 71,800 hits. The Web site sourceforge.net has numerous open-source PHP applications (most are free) that you can download and install. In a recent article I mentioned SugarCRM as an example of a full-blown customer relationship management application. This is available in both free and fee-based editions and is comparable in functionality to Microsoft Dynamics CRM-for much less money. Other prominent applications written in PHP include wiki software, used to run sites such as Wikipedia.org.

I mentioned earlier that the geeky origins of PHP are both its strength and weakness. It's a strength because the open-source community is constantly contributing to the PHP code base. Currently, over 5,000 functions are shipped as part of the standard PHP installation, and many plug-ins are available from open-source contributors. The downside to this, though, is the lack of a central profit-driven controlling body for managing code changes and assuring quality.

Most board members on open-source projects are volunteers who also have "day jobs," so there is a potential for mayhem in managing code releases. This is characteristic of open-source versus commercial software organizations and is a potential issue even with other open-source projects such as Apache. With PHP, this is mitigated somewhat by the presence of Zend, which is a for-profit company that was formed out of the open-source community and still has strong ties to it.

Getting Started with PHP on the System i

Zend has a Web page with information about Zend Core for i5/OS. (You need to be at V5R3 or V5R4 in order to use the Zend Core.) This is the engine that plugs into the Apache Web server to make your PHP scripts actually run. On this page, there is a link to the User Guide, a 102-page PDF document written by Zend (not IBM) that explains how to install it and documents the various System i-specific functions that Zend has provided to support the i5/OS's unique programming environment. For example, Zend has created functions for calling existing programs. This allows you to leverage your existing code base. For instance, you might have a complex pricing routine written in RPG. You can call this directly from PHP, which gives you the best of both worlds. Zend has also provided functions to access the native database on the System i, so RPG programmers can use functions similar to those used in RPG for accessing data.

Once you've installed the Zend Core, you can start writing a test script. For example, the typical "Hello World" code might look like this:

<?php   print "Hello World!";   ?>

You can save this as a text file with a .php extension to a directory on your IFS, say as "helloworld.php." When you install the Zend Core, the install process creates an initial Apache Web server configuration to support PHP. This will have a line that maps a URL to the directory path for this script. For example, suppose this line is in your config file:

DocumentRoot /www/zendcore/htdocs

If you store helloworld.php in the htdocs directory, you can run it at this URL:

http://192.168.0.128/helloworld.php

(192.168.0.128 is just an example IP)

Generally, you might want something a bit more robust than this, with HTML tags to construct a complete page, but at least you can use this to test that your install works.

What PHP Is Not

PHP is not a development tool. However, many development tools, or IDEs, make it possible to write PHP code. The table below lists some examples.

Development Tools
Enterprise-wide commercial offerings Zend Studio Professional,
NuSphere's PhpED, Komodo IDE
Simple commercial offerings Zend Studio Standard, PHPEdit, PHP Designer
Open source Eclipse, Maguma Studio
Free software HTML-Kit
HTML editors Macromedia Dreamweaver, Microsoft Expression Web
Simple text editors Textpad, Notepad


Notice that I listed Notepad. Since PHP is written in simple text files, a developer can use Notepad to write PHP. However, all of the IDEs shown also include integrated FTP clients, which are necessary for uploading local files to the Web server. On the System i, you could save your files locally and then copy them to the IFS as a mapped Windows directory, but it's probably easier (and faster) to use the FTP facilities built into these tools.

So Come Join the Party

Now that you know the basics of PHP and how to get started, I encourage you to take a serious look at PHP. IBM and Zend have invested heavily in delivering PHP to the System i. I believe this will breathe new life into the platform, resulting in its becoming less proprietary. I also believe that programmers will enjoy programming in PHP and that many real-world business applications will be built with it. So come and join the PHP party!

Duncan Kenzie is President and CTO of BCD Technical Support, the development and support group for WebSmart, a popular iSeries Web development tool, and Nexus, a portal product specifically designed for System i, iSeries, and AS/400 servers. Duncan has 30 years of experience on the midrange systems platform creating software for both green-screen and native Web environments.

Duncan Kenzie
Duncan Kenzie is President and CTO of ExcelSystems Software Development Inc. Duncan’s company is responsible for product development and technical support for BCD International Inc.’s (www.bcdsoftware.com) product line. Duncan has a BA in English Literature from the University of Waterloo, Ontario, and enjoys writing on a variety of subjects. Duncan is a frequent public speaker and has been writing articles about the midrange platform since 1985. He has also been involved in producing programmer productivity and business intelligence tools for 25 years and is the technical lead on products such as WebSmart, WebSmart PHP, and Nexus, leading System i Web tools.  Duncan still enjoys programming, and studies in leadership and self-improvement. He can be reached at This email address is being protected from spambots. You need JavaScript enabled to view it..
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: