“We don’t even teach PHP,” or Learning the Fundamentals

The official PHP logo created by Colin Viebrock

One day in February my dad gave me a call; usually, this is so he and my mom can FaceTime with their granddaughter since they live across the country, but this time my dad asked me if I wanted work on a job he was in the middle of. He is the owner of a small internet marketing business where one of his services is to create websites for other small businesses, all based on the WordPress content management system. His request was simple enough: his client wanted an interface for a user to enter a zip code and see who the sales representative was for that area, with data such as the representative’s name, number, and e-mail. I knew immediately how I could go about accomplishing this, and I could probably do it under an hour. After all, I had already passed course 170 at Launch School in where I used Sinatra to process form requests, and I had just recently finished course 180 which was about SQL and relational databases (including how to use Sinatra to make a request to one). Seemed like a quick way to make some cash — my first job as a web developer!

However, there was one glaring problem: WordPress is PHP based, and I didn’t know PHP.

Now, the rational thing may have been to continue with the HTML and CSS course I was in and tell my dad “no thanks.” After all, Launch School warns students about getting distracted from the curriculum, and that’s exactly what this could turn into. While learning PHP as a kind of excursion would be nice, this would require me to put the main curriculum on the back burner as I would essentially need to crash course myself in PHP and build the needed components for the website in about two weeks. This, compounded with the fact that it was less than a month until my wife’s due date with our son, should have probably led me to believe that that it would be best to let this pass.

So, of course, I found myself at the local Barnes & Noble, scoping out any books they had on PHP and cross pricing them with Amazon (look, I’m not exactly rich at the moment. If it’s any consolation, I bought a different book from them a few weeks later). I came across Luke Welling and Laura Thomson’s PHP and MySQL Web Development, and after checking out some reviews, went ahead an purchased it. For roughly the next two weeks I would work a few hours on the 201 course, and then spend the rest on learning PHP and how it works with MySQL.

Before I go further, I think a bit more context will help. I am currently still in the midst of the core Launch School curriculum, and though I would very much like to apply for the Capstone program, New York and San Francisco are not viable options for my family and I. Thus, I have always been a little nervous as to how I would find a job after finishing the program. What was so great about my little diversion into PHP is that it proved to me that what Launch School’s instructor Chris Lee emphasizes: once you understand the fundamentals of programming, you can learn any language.

As a sidenote, the title of this article is a quote that Chris said in one of the lecture videos in the orientation course and that he told me personally in my phone interview, in which one of the graduates of Launch School was hired as a PHP developer even though Launch School doesn’t teach PHP.

This dawned on me as I began reading through Welling and Thomson’s book. The first set of chapters are a crash course in PHP, including the use of operators, strings, variables (including scoping rules), loops, object-oriented programming, blocks, i.e., the same concepts that are largely covered in courses 101 to 130. The key difference I saw from a programmer’s standpoint — since I’m guessing Ruby and PHP can be very different under the hood — was that the syntax of the two languages were different, but that many of the underlying concepts were the same.

There are, of course, some differences that stuck out. It was in course 170 that for the first time I learned how to use Ruby in web applications. What surprised me so much about PHP is that by using particular tags (<?php and ?>) I was able to embed PHP directly into the HTML, like such:

An example of embedding PHP in HTML

The example is a little contrived, but essentially it takes the value of the variable $money and runs it through a switch statement, which, though different in name, is essentially the same as Ruby’s case statement. There are, even here, some subtle differences: you need to break each of the case statements (which are equivalent to when in a Ruby case statement) because PHP will continue to execute the following statements after the first is activated unless it finds a break. In other words, had I not put a break at the end of the case statement for “10”, both “Gettin’ a little low, there…” and “You’re broke!” would have been printed within paragraph tags, rather than just the one that met the condition. It’s also worth mentioning that not everything is an object in PHP, and that unlike Ruby, the last evaluated expression is not automatically returned — you will usually need to explicitly use the return keyword if you want something returned (and, no, echo doesn’t return nil the way puts does).

So by the end of those two weeks, I had a very basic understanding of PHP, and I was able to create a rough draft that would fulfill the client’s wishes: the program should have connected to the hosted database, and returned the information. However, the client eventually decided that the functionality was unneeded, and so the program was dropped. But, since I had done all the research and work thus far I still got paid. I must say, it was pretty rewarding to see a check come my way for programming!

The conclusion to all of this, especially for those who are unable to apply for Capstone, is that you will be fine. By having a strong grasp of the fundamentals I was able to pick up on how to use a new programming language and another Relational Database Management System (which I didn’t get into here), something that would have been ludicrous to try back when I was just starting to learn how to program. Had I not known the core concepts taught in the back end courses I would not have been able to pick up on PHP so quickly, as some of these things (such as return values) are not talked about with much detail within the book. While navigating the job hunt may be a bit more difficult, you will indeed have the skills to carry you forwards.