Now that we’ve just finished a great collection of Tutorials about WordPress, it’s time to dig into PHP. Why dig into PHP? Well we talked a little bit about all of the open source software packages that make WordPress possible, but what we didn’t mention is that the majority and bulk of the program is written in PHP. With WordPress powering almost a full twenty percent of websites worldwide, and PHP being the language WordPress is written in, we really ought to have a good understanding of PHP and how it works! PHP stands for PHP Hypertext Preprocessor. It actually originally stood for Personal Home Page Tools, which does seem to be a little easier to digest than the current PHP Hypertext Preprocessor, but I think we’ll be ok! So without further ado, it’s time for Random Bits of Awesomeness in PHP!
Server Side Scripting Language
PHP is a server side scripting language. What does this mean? Well, we had a good look at how JavaScript works in a prior tutorial, and we know that JavaScript runs in a Web Browser in most cases. PHP lives on a server, and it’s code executes on that server. Only the result of PHP output makes it to your browser, unlike how actual JavaScript can be delivered over a network to your Browser so it can execute.
What is a Script vs a Program
A computer program and a computer script are similar, yet there are very important differences. Let’s take a look at a few of the differences between the two.
Script
A script typically triggers in response to an event. In the case of PHP, the event is the action of a user requesting to view a webpage with their web browser. This is what sends an HTTP request to the server, and triggers the execution. Once the script starts to run, it does so from top to bottom in a very linear fashion. This happens quickly and with no user interaction. Once this process is complete, the script shuts down so to speak until another request is made.
Program
Programs are much different. You are probably more familiar with computer programs than you are with scripts. A program is launched, and then it continues to run without the need for additional requests being made. It also may jump around within the code as the software runs depending on user interaction, unlike the top to bottom nature of a script. For example, you likely are familiar with Microsoft Word or Microsoft Excel. These are computer programs that when launched, continue to run and wait for user input, then take action on the input provided.
Blurred Lines
Much like Robin Thicke, the distinction between a script and a program can begin to have blurred lines. That is to say, as scripts become more complex, especially when you’re talking about high level frameworks and development environments, they begin to closely resemble the nature of a true computer program. So what’s the big deal you say? Well, it’s not a big deal really. It just helps to remember PHP’s humble beginnings as compared to where it stands today in all of its modern object oriented design glory.
What does Server Side mean?
When we say server side, we mean the actual code is installed on a remote server. The only environment under which that code can execute is on that very server. It’s in many ways much safer than JavaScript. <flamesuit>
JavaScript has it’s place, and contrary to the Node.js fans among the populous, it is not on the server! </flamesuit>
. PHP is designed to work with HTML. You can embed PHP inside of HTML, or use PHP to generate HTML to be sent across the network to a users web browser. Files use a .php extension to tell the server that there is PHP code contained within the file that must be interpreted and executed. The syntax is a derivative of the C Family of languages. In fact the PHP engine itself is written in C, which is for all intents and purposes, the de facto language of all of computer science. PHP is very flexible and can be arranged in a super disciplined and clean style as is the case with modern frame works, or it can be intertwined like Spaghetti into your HTML to create various effects. The only limit is your imagination, so get your favorite imagination stimulant ready.
The Glorious History of PHP
If you’ve ever listened to any of the great Douglas Crockford’s lectures on JavaScript, you’ll know that Doug likes to talk about the entire spectrum of computers and computer science all the way back to Grace Murray Hopper who was born on December 9, 1906. Grace is credited with being a true pioneer in computer science. It is always fascinating to listen to experts in the field discuss history and travel through time so to speak to arrive at where we are today. In the case of PHP, it’s life began in 1994 at the hands of a genius named Rasmus Lerdorf. Rasmus used the C Programming language to create the the very first iteration of PHP, and C is still what powers the PHP engine today. Early on, PHP was quite limited but by 1998 Andi Gutmans and Zeev Suraski joined the project and rewrote the PHP engine for version 3 of the language. It was also at this time that the naming convention of PHP changed from that of Personal Home Page tools to PHP: Hypertext Preprocessor. Some say this was the point at which we should have begun to fear PHP, when these guys decided to make use of a recursive acronym to describe their creation. Fear not! PHP is awesome, no matter what we call it. Fast forward to the Y2K, and PHP had another major overhaul. This is when Andi Gutmans and Zeev Suraski formed Zend, the PHP Company. They rewrote the engine again, and began to incorporate more modern techniques, and the beginnings of OOP or Object Oriented Programming techniques into the language. PHP 5 came out in the year 2004, and it is from this version that the modern iterations of PHP that we will discuss here are derived. PHP is now a modern and powerful scripting language, and we’ll learn all about it as we tackle the ins and outs of how to use it.
The Use Case for PHP
As you began your adventure as a web developer, you learned HTML, and while it was great to learn how to create files and place them on a server for others to view with a web browser, you began to see the limits of this approach. HTML is static, you can’t embed logic or behavior into HTML. Along comes PHP to the rescue.
- PHP is Open Source PHP is open source software which means you are free to download it, use it, modify it, or otherwise do whatever you want with it. There are no license fees or restrictions to worry about, and did we mention, it is free.
- PHP is cross platform PHP will run on Windows, Linux, OSX, or any other flavor of UNIX you can think of. You are not restricted to a proprietary platform with restrictive lock in.
- PHP is Powerful and Scalable PHP is simple enough to build a super basic website for your small company website or blog. It will also scale to power multi billion dollar companies like Yahoo and Facebook, both of which rely on PHP to support their infrastructure. Many of the very most visited high traffic websites in the entire world run on PHP.
- Made for the Web PHP was built for the web. The internet and world wide web rely on many different protocols and aspects of the IP stack to run. PHP has support built right in for dealing with HTTP hyper text transfer protocol, FTP file transfer protocol, DNS domain name system, Streams, Sockets, and more. PHP was built for the internet.
- Object Oriented PHP now has full support for the full range of Object Oriented techniques available. That means you can use namespaces, classes, objects, inheritance, control visibility, and use any of the tried and true design principles of computer science.
- Best Documentation in Town The PHP documentation is arguably the best language documentation available for any of the modern languages. Every single function available is clearly documented, with community comments included for each function. These comments will be invaluable to you as you learn since many people before you have probably struggled with and solved whatever question you may have. You’ll find the code snippets to be super helpful.
- Huge Development Community There are over 20 million websites on the internet that run PHP. That’s a lot of websites, and a lot of software developers that wrote all of the PHP to run those sites. Any problem you come across has most likely already been solved, all you have to do is learn how the language works, and learn to implement the code available to you. Once you have this skill, you can then make small tweaks and modifications to the code to make things work exactly as you’d like them to. It’s all very fun!

Getting Started with PHP
As we go through this PHP tutorial series, we’ll make every effort to cover the fundamentals of the language soup to nuts. These next articles are not for the advanced programmers out there, unless they want to come back and refresh the basics. In many ways, it’s the basics and the fundamentals that are the most fun to learn. So moving forward, we’ll have a lot of ground to cover. We’re going to need to get PHP installed in some way shape or form so that we can begin working with the language. We’ll set up some really cool testing tools so you can quickly test out the snippets and make your own. Once we have a bit of a foundation, we’ll start looking at all of the features of the language. Topics to cover include Data Types, Control Structures, Expressions, Logical Operators, Loops, Functions, Debugging, Forms, Sessions, Cookies, MySQL Database Basics, and more.
The What is PHP Summary
This was a fun crash course on the history of PHP and how we can begin to learn about it and leverage the language for our own projects. With over 20 million websites already using PHP, you’ll be in good company learning about the language as well.