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. Some like to state that PHP as a programming language is dead but that’s not true.

There are different versions of PHP that you can install on your server, with the newer PHP 8.0, 8.1, and 8.2 offering significant performance improvements over the previous versions. 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 and PHP 8

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

Like other programming languages, there are different versions of PHP that you can use. PHP 5, 7.0, 7.1, 7.2, 7.3, and 7.4 are older versions of PHP that have reached their end of life. This means they will no longer receive active support and have ceased (or will soon cease) receiving security support.

PHP 8.0, 8.1, and 8.2 offer significant performance and security improvements. At Kinsta, we support the following PHP versions with our custom self-healing configuration:

You can even change PHP versions with a single click. All you need to do is log into your MyKinsta dashboard and select the relevant WordPress website.

Then, go to Tools and scroll down to PHP engine:

Change PHP version in MyKinsta dashboard
Change PHP version in MyKinsta dashboard

Here, simply use the Modify dropdown box to switch to a different PHP version.

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:

WordPress PHP files
WordPress PHP files

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

WordPress Twenty Twenty-One PHP files
WordPress Twenty Twenty-One PHP files

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

PHP files in a WordPress plugin
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 are 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 of connecting the server-side nature of PHP to your WordPress site.

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

WordPress Twenty Twenty-One PHP files
PHP files in the default Twenty Twenty-One theme

You’ll see that there are separate PHP files for things like “comments.php”, “footer.php”, “header.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:

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

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.

What Is a PHP Framework?

A PHP framework is a platform that enables developers to create PHP-based applications more efficiently. It consists of code libraries that help you perform common functions like form validation and data sanitization.

This is a much faster alternative than writing your own original code. However, speed and convenience aren’t the only reasons to consider using a PHP framework.

PHP frameworks also offer an easy way to access quality coding practices. Here, in Symfony, you can see that functions are organized neatly into different directories:

An example of a PHP framework directory
PHP framework directory

Additionally, PHP frameworks encourage refracturing of code and DRY development (Don’t Repeat Yourself). As a result, you’ll have a leaner codebase that’s easy to maintain. Plus, you don’t need to worry about maintaining the core framework yourself.

What’s more, PHP frameworks offer a simple way to make your PHP-based applications more secure. Although you’ll still need to write secure code, a framework can reduce the chance of hacker exploits. Some frameworks also provide built-in data sanitization protection against common PHP security threats like SQL injections and cross-site scripting.

3 Best PHP Frameworks

Now that you know a bit more about why to use PHP frameworks, here are some of the best options to consider.

1. Laravel

Laravel PHP framework
Laravel

Laravel offers clean architecture and everything you need to build a web application. It enables tons of features, such as user authentication, file storage, database migration, and much more.

It’s also super easy to get started with Laravel. You don’t even need to install PHP, a web server, or any other software on your system. Instead, it comes as a pre-packaged development environment that’s lightweight, fast, and secure.

2. Symfony

Symfony PHP framework
Symfony

Symfony functions as a PHP framework and as a collection of PHP components to build websites. It’s one of the most flexible options, enabling you to choose the exact components that you need for your project.

Additionally, Symfony supports tons of databases, including Drizzle, MySQL, and Oracle. Better yet, Symfony is commercially backed by Sensio Labs, so you’ll find lots of support available (unlike other PHP frameworks).

3. CodeIgniter

CodeIgniter PHP framework
CodeIgniter

CodeIgniter has very minimal configuration, so you can get it set up quickly. Like Symfony, you can add the components that you want. Therefore, you can easily build a light application with no bloat.

What’s more, CodeIgniter is a scalable solution that helps protect you against security threats like cross-site scripting. Plus, you’ll find some performance-based features like caching to speed up your apps.

Hosting for WordPress or PHP-Based Apps

To get your website or application up and running, you’ll need to find a quality web host. At Kinsta, we offer tons of solutions, so you’re sure to find an option that suits your project and budget.

What’s more, all of our plans are built on our fast, secure infrastructure. You’ll also get access to edge caching and our state-of-the-art Content Delivery Network (CDN) to supercharge your loading times.

Additionally, we provide you with your very own staging site, which is ideal for running updates and testing changes before pushing them to your live site. And it couldn’t be easier to push your changes to live from your dedicated MyKinsta dashboard.

If you’re building a Laravel-based application, you might want to check out our Laravel hosting package:

Kinsta Laravel hosting
Kinsta Laravel hosting

With Kinsta Laravel hosting, it’s easy to manage your apps, databases, DNS, and analytics from your dashboard. You’re also able to connect your dashboard to GitHub, GitLab, or Bitbucket.

Once you’re all set up with your new hosting plan, you can manage your application and add/remove features from your app via MyKinsta. For example, the Tools section allows you to restart PHP and switch PHP versions with just one click.

Meanwhile, you can test PHP versions in a free staging environment first for extra peace of mind. All you need to do is use the Live dropdown menu at the top of the interface and choose Staging:

Kinsta staging environment
Kinsta staging environment

Then, once you’ve determined that your changes are safe to run on your live app, click on Push environment and then select Push to LIVE.

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.

With 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. Make sure to check out our guide on how to use the phpinfo() function.

And if you want to develop your own WordPress themes and plugins, learning PHP is essential. But you can also get started with PHP frameworks to speed up the development process.