In my continuing mission to demystify the world of tech for everyday people, I’ve been writing about different coding languages and what they do.
In this article, the focus is on PHP.
With PHP, we’re getting away from the pretty, relatively easy-to-grasp front-end languages of HTML and CSS, and delving into the dark murky depths of sever-side technology. But don’t be scared! I’m here to hold your hand, hold the torch, and hopefully shed some light onto it. Here we go…
What is PHP?
PHP stands for “Hypertext Preprocessor.” It’s a coding language used by WordPress to communicate with the database – where all your posts and pages are stored. For example, PHP would be used to tell WordPress to display a list of posts from a certain year, or a certain category.
An example of PHP code is:
Eek! Looks different, huh? But don’t worry, because you won’t really need to know what it all means. I’ll explain in a second…
How to edit PHP
Nah, just kidding. You can, but you need to proceed with caution.
Really, the only time I ever need to touch PHP code is to add functionality into WordPress’s functions.php file. And I’m usually just following a tutorial that I grab online, when I have a specific thing that I need to achieve.
Let me give you an example.
When I set up the payment system for my online courses, I wanted to change the button that says “add to cart” so that it says “register.” So I followed these steps:
1. Google “WooCommerce change add to cart button text.”
2. Click through to one of the search results: a tutorial.
3. The tutorial gives a code snippet to paste into my functions.php file:
4. Access the functions.php file in my theme folder via FTP*
5. Paste in the code snippet
6. Press save.
*It’s important to access the file via FTP to change it. It certainly feels easier to go in via Appearance>Editor to do a quick fix. But if you get something wrong in the code, then your site will go down, and you’ll need to access it via FTP to fix it anyway.
This is about as technical as I would suggest people get with PHP on their websites.
Are you ready to try it out? Leave a comment to let me know how it goes!