PHP stands for Pretty Hot Pantaloons
well, only in my mind. But read on to find out what it really is all about!
I forget exactly when I first heard of PHP
I believe it was spring 2020. I was just beginning to feel confident using HTML and CSS to make websites. Just writing the HTML and CSS rules took me forever, but I no longer felt avoidant and embraced the process of making websites.
Let’s touch upon why making websites took me so long. After all, how complicated could making a simple static website be? Well, we are talking about me after all, the master of (unconsciously) making mountains out of molehills.
While I was dragging my feet a bit, what was truly taking me so long was the repetition. If you have ever made a website, especially a multipage website... you know that there is A LOT of repeating the same code.
I will never forget how scared and unprepared I felt when I was first asked to use PHP. The task was simple. Use PHP to include the website header (like the one above) across multiple pages. Staying true to his goal-based approach, before Derek even asked me to use PHP, he touched on the benefits of using it.
Breaking up your HTML into reusable components.
What does that really mean though?
What if there was an easier and quicker way to write all that HTML for your header?
Well, that is where PHP comes in!
**That first section class should say site-main. I’m working on those typing skills!
Notice anything funky about this code? What’s with all those question marks? <?php ?>
What is that?? Is HTML having an identity crisis? And what’s up with the .php
file extension?
BUT WAIT. BEFORE YOU GO and type this code into your favorite code editor (*cough* sublime *cough*)… There is something you need to know.
A bit more about PHP
So I told you what PHP doesn’t stand for, so what does it mean anyway? Depending on who you ask, PHP is either a recursive acronym (an acronym that refers to itself) for PHP: Hypertext Preprocessor or Personal Homepage.
According to php.net (the official documentation)
PHP is a popular general-purpose scripting language that is especially suited to web development.
Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.
What isn’t mentioned here, and it is very important… is that PHP is a server-side scripting language. That’s right, you’ll need a server (just fancy words for special software) that has PHP installed on it to successfully use the language.
I’ll leave the finer details to the Perpetual Education PHP lesson, but the gist of it is that... the PHP scripts that we write are interpreted on a web server with PHP installed, and turned into HTML when you load the PHP script in your browser.
Your web browser has no idea this is happening, all it cares about is that it can read the document... despite the weird extension. the .php
extension exists to inform the PHP web serve to interpret this file NOT as a .html
file... but as a .php
file.
But enough acronyms, I don’t know about you but why I am learning a language really matters to me. I learned English because it was taught to myself and the other students in our formative school years, so we can all have a common language to communicate.
I learned HTML (Hypertext Markup Language) so I can markup content and describe it to the browser (and search engines). But also, it is a common starting point for many a developer.
I learned CSS (Cascading Style Sheets) so I can style my HTML.
And FINALLY… I learned PHP (begrudgingly, out of fear) so I can template my HTML.
Look at the include()
statement on the first line. As you can hopefully see, I used PHP to include a separate document called header.php
. All the markup for the header section of the website is there. As you can imagine, this is much more time-efficient than repeating <header>
<nav class="site-menu">
<a class="link" href="#">link</a>
<a class="link" href="#">link</a>
<a class="link" href="#">link</a>
<a class="link" href="#">link</a>
</nav>
</header>
Times however many pages you need that code on your website! Holy carpal tunnel syndrome Batman. PHP to the rescue!
I don’t want to overwhelm you with too much information. Plus I get the feeling this stuff will show up in a future PE lesson soon.
That’s all for now folks.