Monday, April 19, 2010

One way to succeed with PHP on IBM i

One question I field a lot is “Do I really need to know HTML in order to program in PHP?” In my opinion the answer is an unequivocal “YES!” And I can’t put enough exclamation points after that YES! As many who will read this are IBM i developers, I feel comfortable challenging you to think back to when you learned RPG and were first exposed to interactive programming. There is this funny little language called DDS (Data Definition Specifications) that was used to describe data, display formats and report formats. This odd language was so simple in its design and so obvious in its use. But it has started to fall away with the advent of SQL, report writers like Query Manager & DB2 Web Query and newer UI technologies such as PHP, RPG-CGI and others. Many in the RPG arena I have talked to don’t seem to think there was any effort expended in learning DDS. Seems a bit strange but I challenge you to consider, if you can, the number of hours you spent learning the nuances of DDS for interactive processing. And if you have trouble, think back to your first subfile program and the first time you struggled with a subfile issue.

Why is this so important to me? Well, you see, a good friend of mine was trying to learn PHP in my class and he got so frustrated he walked away. Not because he could not grasp the PHP but because he struggled with the application of PHP in the web presentation realm: i.e HTML. I feel that I let him down all the time he was struggling assuming he would just “pick it up”. I should have added more HTML content to the class or offered more assistance. There was a huge gap and he ultimately felt it was no longer worth the time or stress. I have spent a great deal of time reflecting up upon this issue and have decided to recommit as much energy as possible into encouraging IBM i developers to learn HTML as soon as possible.

So where do I go to learn HTML? There is an abundance of resources on the internet that are fabulous for learning HTML. Since there are far too many resources to discuss that cost absolutely nothing I prefer to give one example of each and allow you to spend a little time using Google to discover another. Better yet, add a comment to this article with your favorite place to find good info about general web development. First there are the free resources like, which is a great place to start. Their online list of tags and examples are well worth the time to review. Second there are books. My favorite is the Head First HTML with CSS and XHML. This book takes the knowledge you gain from the places like w3schools and applies the concepts in an actual application. Granted they are basic in nature but that is still a great start. Third are classes like the ones at the local community college. Moraine Valley Community College in Palos Hills, IL hosts a 16 week class on HTML and Java Script.

Wait Mike, you started talking about HTML and now your babbling on about CSS and Java Script! What gives? Yes, I realize I am all over the board, here. The first thing any IBM i developer must accept about the web programming realm is that this world is different than the world of RPG and COBOL. Suck it up and get used to it. I can’t change it for you and neither can IBM, Microsoft or Google. But we can make it a little easier to understand. So let’s reign it in with a few IBM i analogies that might help. HTML has to do with formatting. Think of the display attributes and subfiles you build using DDS. HTML controls the look and feel of your site. Now if you think about a good application that you built using DDS you probably got into the use of reference fields. In many cases this is where you set up standard sizes and attributes for many data elements in your display files. The field reference file, sometimes referred to as a Data Dictionary is somewhat akin to the Cascading Style Sheet or CSS. CSS is a super-charged version of the data dictionary and is used to maintain the consistency of website layout across multiple pages. So if you choose that your HTML table (something that looks a lot like a subfile) should always have a grey background, bold piping, heading in italics and every other bar alternating a green background then you would want to use a CSS. The CSS saves you the trouble of hard coding formatting on every page and lets you focus more on the application when working in PHP.

But what about Java Script, Mike? Yes, dear JavaScript. Well, it used to be that folks wanting to add special functionality to their web pages would occasionally use JavaScript. In fact, I remember the early wars where folks would disable JavaScript in hopes of making their browsers safe. As in many risks to humans today the benefits far outweigh the risks. Many of us are taking JavaScript for granted when surfing web pages like Google and others. The “magic” that auto completes search box entries is often times JavaScript! And, if you think you need to deliver that functionality for your users you are absolutely correct. Why? Because they are surfing Google, too and expect jst as much from you as they get form the hundred or so web developers at Google.

The good news is that this is all achievable. But as the old Chinese proverb says, ‘The journey of a thousand miles begins with a single step’. You too must realize that this can be learned but you have to start somewhere. So, what is Mike’s prescription? Here is a guidline and not a guarantee:
- Go to w3schools (or some portal) and start learning HTML (30 days)
o You can program HTML on your IBM i or your PC. You pick.
o The only way to learn this is by doing it
o If you are looking for examples of how to do something in HTML just go to a given web page that has it working and click “View?Page Source. In Firefox it is CTRL-U.
- Now you can start learning PHP. (60 days)
o Come to Zend for the PHP for RPG Programmers course
o But there are books
o And online portals to help with that too
- Get some CSS training (15 days)
o Again books and online tutorials are great.
o Don’t forget about your local community college
o Or maybe your local user group…
o Go to for examples of the power of CSS!
- By now the JavaScript stuff will start making sense (30 days)
o Same as above
o No longer an option, thou shalt learn JavaScript!
Please understand that a lot of what is placed in this article applies to just about any web programming paradigm. PLEASE do not let some slick sales person sell you on how easy their “tool” is to learn and use and that you will never need to learn a given technology although you make a living developing in it. It is important to understand how the technology works for you to support it. Tools can help bridge the gap and accelerate the learning, in some cases. But you will need to learn these basic technologies to do web development regardless of your path.

Lastly, the only way to learn this stuff is to play. Get your hands dirty and “JUST DO IT!” The Matrix was a movie that showed how easy it is to learn things and until that becomes a reality you need to start at the beginning and work through it.

Good luck!