TechTip: PHP 7.X Is Finally Here

  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times


PHP 7.0 is here. Hurray! For the IBM i, that is. It took a while, but now it’s a fact. Read all about it.  

Almost two years ago, I did a TechTip on PHP 7.0 and what it had to offer when it was first released by Zend. In fact, I did two of them. At that time, the word on the street was that it would be available for the i within a few months of that date (July 2015). But it took a bit longer than anyone expected. It took, in fact until just a few weeks ago. But now, finally, the latest release of PHP is available for the IBM i community to use and abuse. And, in fact, it took so long that what is now available to the i is not just PHP 7.0, but PHP 7.1.    

Long Wait

Why the long wait? Let me explain.

PHP is a web language, and it is more or less open source. When I say “more,” I mean that it is open source in that many people contribute to the new releases. And when I say “less.” I mean that the community that supports it is not a free-standing entity like the ones for Apache or Eclipse, but rather Zend. There is nothing wrong with that, and the issue here is not related to that fact.

But when it is released for the web by Zend, it is not automatically available on the IBM i. Remember, PHP runs on the i but it is not really native to the i. It requires a set of other products, referred to as the PHP stack, to run along with it in that environment.

Now, if I am a straight web programmer, then there are several places I can go to get the PHP stack, and when a new release of PHP comes along, all I have to do is download it into my stack in place of the old version, and I am ready to go.

Theoretically, you could do the same on the i, but the fact is that’s the hard way to roll. Instead, on the i, most people use a pre-packaged stack made available by Zend within the Zend Server product. As a result, we need to wait for Zend to incorporate the latest release of PHP into the Zend Server product before it becomes generally available on the i. And that has just happened with the release of Zend Server 9.1. 

And What Does That Mean?

What it means is that now, in one fell swoop, i-based PHP programmers get three things: First, they get access to the latest version of Zend Server, 9.1. Second, they get, as part of that, PHP 7.0. Third, as an extra special bonus gift because it took so long to get 7.0 into Zend Server, what is actually delivered is not 7.0 but PHP 7.1. 

Each of those items is worth an article on its own and at some point in the future, I will outline exactly what is in PHP 7.1 and Zend Server 9.1. For now, however, in addition to announcing what is suddenly available, we will take a quick look back at 7.0 and remind ourselves why this is such an important release.

PHP 7.0: Why Should I Care?

It’s a fair question. I mean I suppose it has some fancy new stuff in it, like the <==> operator, which gives you not just an equality statement but actually a three-way equality and some additional things for handling nulls. In fact, it has quite a few new enhancements that you might want to take advantage of, and for a more detailed review of those, I would refer you back to the two articles I linked to at the top of the page.

But the primary thing that I want to zero in on is that 7.0 provides speed. 

All in all, based on the benchmarks Zend has done, 7.0 (and therefore 7.1) is about twice as fast as the previous release, 5.6. 

In addition, it is not only faster but also much more efficient in the way it uses space and handles data, particularly arrays. 

The result is a version of PHP that takes fewer resources and can handle either the same workload faster or else a greatly increased workload without a resource hit. What is responsible for the improvements? Two things. 

The first one was to replace the old PHP engine with a new one, called PHPNG. This refactored engine was much more efficient in how it handled data—most specifically, arrays. With a streamlined structure and better data handling, PHPNG is able to blow away the response times achieved by the old engine in 5.6.

The second was to add the Abstract Syntax Tree structure to the compile process. What this did was to represent the script as a tree structure with the nodes representing the functions in that script. The addition of this structure allowed the compile process to separate the syntax checking from the code parsing so that many of the syntax-related rules that are part of the 5.6 engine are no longer needed in 7.0. The result is cleaner, simpler code. Remember, PHP is not a true compiled language and when we talk about a PHP compile, we are talking about something that happens when the script is loaded into the server and run. So a faster compile means a faster run.


I suppose we could focus on why it took so long to get this faster PHP into Zend Server, but I’m a glass three-quarters empty kind of guy, so why bother. It’s here and that’s what really matters. And remember, in an upcoming TechTip, we will look at what 7.1 has to provide (some totally useful stuff), along with what goodies are in Zend Server 9.1 (definitely worth the upgrade).