12
Wed, Jun
4 New Articles

PHP, the Everywhere Web Language

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

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.

http://www.mcpressonline.com/articles/images/2002/seiden_alan_iTechMgr_PHPV4--06070600.png

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'




 
 
 


$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("
",
odbc_result($result,1),odbc_result($result,2),odbc_result($result,3));
   }

odbc_close($db);
?>
Countertop CodeShort DescriptionLong Description
%s%s %s




The HTML result is shown in Figure 2.

http://www.mcpressonline.com/articles/images/2002/seiden_alan_iTechMgr_PHPV4--06070601.jpg

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 email address is being protected from spambots. You need JavaScript enabled to view it..

Alan Seiden
  Alan Seiden founded Seiden Group to help IBM i shops design and implement high-performance web and mobile applications using PHP, DB2, RPG business logic and Zend Framework best practices. Alan and his team work closely with some of the best minds at both Zend and IBM on behalf of their clients.With a passion for open source and community, Alan co-developed the popular PHP Toolkit with IBM. He was one of the first Zend Framework certified engineers; co-founder of the NYC Zend Framework Meetup; charter member of IBM/COMMON's PHP Advisory Board; and a consultant for IBM's manual PHP: Zend Core for i5/OS. An award-winning speaker, Alan has been called "the performance guru of PHP on IBM i." He shares his expertise regularly at conferences and user groups such COMMON, ZendCon, the RPG & DB2 Summit, OMNI, the Northeast Users Group Conference, OCEAN and WMCPA. He also mentors other developers within the Club Seiden forum.In his spare time, Alan plays the trombone and studies and teaches the Feldenkrais Method® of Somatic Education.Subscribe to Alan’s monthly newsletter PHP on IBM i Tips.  Follow Alan on Twitter: @alanseiden and LinkedIn: www.linkedin.com/in/alanseidenMore on Alan
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: