What Is PHP? How Is PHP Used in WordPress?

Updated on July 19, 2018

PHP is an open-source, server-side scripting and programming language that’s primarily used for web development. The bulk of the core WordPress software is written in PHP, which makes PHP a very important language for the WordPress community.

There are different versions of PHP that you can install on your server, with the newer PHP 7.2 offering significant performance improvements. Those performance improvements, plus improved security, are why Kinsta always offers the most recent versions of PHP.

In this post, we’ll explain more about what “server-side” means and how PHP functions. Then, we’ll move into some of the ways that PHP specifically applies to WordPress and WordPress sites.

How Does PHP Work?

In the brief definition above, you learned that PHP is a server-side language. But what does “server-side” actually mean? Server-side means that all of the processing happens on your web server before anything gets delivered to your visitor’s browser.

Here’s an example. Say someone visits your WordPress site. Before sending any files to that visitor, your server will first run the PHP code contained in the WordPress core and any themes/plugins you have installed on your site.

Then, once your server has processed the code, it delivers the output of all that PHP (which is the HTML code that a visitor’s browser actually receives).

The end result is that, unlike HTML, your website’s visitors will never see the PHP code that powers your WordPress site. They’ll just see the already-processed code that your server delivers to their browser.

PHP 5 vs PHP 7

According to W3Techs, PHP is used by over 83% of all websites who use a server-side programming language, with ASP.NET coming in second place with a little over 13% market share.

Like other programming languages, there are different versions of PHP that you can use. PHP 5 is an older version of PHP that is nearing its end of life. PHP 5.6, the most recent PHP 5 version, no longer receives active support, and will cease receiving security support starting in 2019.

PHP 7, the newest version, offers significant performance and security improvements. Currently, Kinsta supports:

You can even change PHP versions with a single click.

Change WordPress PHP version

Change WordPress PHP version

And while we do offer PHP 5.6, we highly recommend that you use at least PHP 7. PHP 5.6 may be needed in some instances where a third-party WordPress plugin is still catching up in terms of support in its code for newer PHP versions. This is rare, but it does happen. If you have a WordPress plugin that doesn’t support at least PHP 7, we encourage you to reach out to the developer and ask for an update.

How Is PHP Used in WordPress?

If you go and download the latest copy of WordPress from WordPress.org, you can open the ZIP file to see that most of the included core WordPress files are PHP:

PHP files in the core WordPress software

PHP files in the core WordPress software

Similarly, any theme that you install is going to include a bunch of PHP files (the screenshot below is the default Twenty Seventeen theme):

Example of PHP files in a WordPress theme

Example of PHP files in a WordPress theme

And any plugins that you install are – you guessed it – also going to be primarily PHP:

Example of PHP files in a WordPress plugin

Example of PHP files in a WordPress plugin

Beyond using PHP for its core files, WordPress also includes a huge number of functions, hooks, classes, and methods that you, or developers, can use to extend WordPress’ functionality in tons of helpful ways.

For example, one of the most well-known functions is the_content();. While this small snippet looks innocent enough, it’s actually what your theme uses to display the entire content of each one of your blog posts.

Yes – that one tiny snippet can turn into a 10,000-word blog post after your web server finishes processing the PHP code. These functions, hooks, classes, and methods a big part of what makes WordPress flexible.

An Example of How PHP Works in a WordPress Theme

Let’s take things a bit further with a quick example connecting the server-side nature of PHP to your WordPress site.

If you go back to that picture of the Twenty Seventeen theme:

Example of PHP files in a WordPress theme

Example of PHP files in a WordPress theme

You’ll see that there are separate PHP files for things like “sidebar.php”, “header.php”, “comments.php”, etc.

If you already use WordPress, those terms should sound pretty familiar. And yes, it really is that simple – each of those files connects to the similarly-named area on the front end of your site.

For example:

  • sidebar.php dictates how your sidebar area looks and functions
  • header.php dictates how your header looks and functions
  • comments.php dictates how your comments section looks and functions
  • etc.

Whenever someone visits your site, your web server takes all those separate PHP files for different areas in your theme, puts them together as specified by your theme, and delivers the completed HTML output to your visitor’s browser.

Do Regular Users Need to Know PHP to Use WordPress?

No! Not even close. The beautiful thing about WordPress is that all of the PHP is already written for you in the form of the core WordPress software, WordPress themes, and WordPress plugins.

While advanced WordPress users can use PHP to make more complicated customizations, casual WordPress users never need to concern themselves with PHP if they don’t want to.

What that being said, there are definitely benefits to learning the basics of PHP. Even just learning the most popular WordPress PHP functions will help you quickly make some easy, but significant, tweaks to your WordPress site.

And if you want to develop your own WordPress themes and plugins, learning PHP is essential.

Was this article helpful?
No, or there was something off

Hand-picked related articles

Use WordPress?

Use WordPress?

Join 20,000+ others who get our FREE weekly newsletter with WordPress tips on how to drive more traffic and revenue to your business!

Consent

You have Successfully Subscribed!

Send this to a friend