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
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.
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.
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.
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?
</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
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.
Thank you for reading What is PHP? – Please do share using the buttons below!