Beginner's Guide for WordPress / Start your WordPress Blog in minutes

What is: PHP

PHP is a programming and scripting language to create dynamic interactive websites. WordPress is written using PHP as the scripting language. Just like WordPress, PHP is also open source.

PHP is a server side language, which means that it runs on your web hosting server. Whenever someone visits your website, their browser contacts your server to request the page. The PHP code runs on the server, and generates an HTML page to send to the visitor. The visitor then sees the HTML page in their browser. They can’t see the PHP script because it’s only on the hosting server.

What is PHP

How Does WordPress Use PHP?

PHP code is what makes WordPress work. A WordPress website stores all its data in a MySQL database. This data includes everything from your blog name and blog post content, to your plugin settings and user profile information.

PHP’s job is to get specific information from the database, and piece it together into an HTML web page. For more details on that process, you can see our guide on how WordPress works behind the scenes.

PHP code is contained in files that end in the .php extension.

If you have ever opened a WordPress zip file, you’ll see that most of the files are PHP files.

For example, in the screenshot below, you’ll notice file names like wp-config.php, index.php, and lots more. Each of these files contains the code used to perform different actions in WordPress.

PHP files in WP

A WordPress theme folder looks very similar. You’ll find files like sidebar.php, header.php, and others. Each of these files makes up a theme’s template hierarchy and displays the different sections of your website.

PHP code needs to be wrapped inside the php opening tag <?php and the closing tag ?>. PHP files can also contain HTML code.

Each PHP tag can retrieve a bit of information from your database. In this example, you can see the PHP code to display your blog name, which is then wrapped in HTML title tags.

PHP in HTML Example

How Does PHP Work?

If you’re looking around on the web for information about PHP, you’ll see it’s a “server-side” scripting language. Unfortunately, that short definition isn’t helpful for beginners.

The term “server-side” just means that all those PHP files in WordPress do their work on your web hosting server. So, in simple terms, when someone goes to your website, WordPress accesses the PHP files to get your database information (like your blog post content) to show it to your visitor.

That sounds simple enough. However, there’s a little problem. Web browsers don’t read PHP. They read HTML.

HTML is a type of scripting language used to create website pages. We refer to HTML as a “client-side” scripting language.

Browsers like Chrome, Firefox, and others are called “clients.” Here, a “client-side” language simply means that web browsers do the work of turning HTML code into what you see on your browser window.


So, if browsers only read HTML and your WordPress website is created in PHP, how can people see your website?

Let’s take a moment and see how the PHP code in WordPress works with HTML first, step by step:

  1. First, someone types in your web address in their browser, or they click on a link.
  2. This sends a request to your web hosting server.
  3. Your server then sends the HTML code over the Internet back to their browser.
  4. Their browser takes that HTML code and translates it into a web page.

However, when you visit a website created with PHP, like WordPress, an additional step takes place.

Before step 3, the server has to run PHP code to create the HTML page, before it can send it to the browser.

WordPress PHP Versions

Just like other programming languages, there are several versions of PHP that you can use. Some versions like PHP 5.5, 7.0, and 7.1 are no longer receiving active support.

As a WordPress website owner, you should use the latest version of PHP. We say this because each new version of PHP fixes security issues and will help to increase your website speed.

Since PHP is such a popular language to make websites, it’s also a target for hackers. So, having the latest version will provide you with the security features and fixes not found in older versions.

We recommend that you use either Bluehost, SiteGround, or WP Engine as your web host because they use the most up-to-date versions of PHP with their WordPress web hosting packages.

Do WordPress Users Need to Know PHP?

WordPress users don’t need to learn PHP to use, operate, or manage a WordPress website. WordPress already has the PHP files you need, and so do themes and plugins so that you can use WordPress with no PHP coding skills.

Most WordPress users never need to know how to code in PHP, but if you’re interested in developing your own plugins, themes, or making advanced customizations to WordPress websites, then you’ll need to learn to use PHP.

We hope this article helped you learn more about PHP. You may also want to see our Additional Reading list below for related articles on useful WordPress tips, tricks, and ideas.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Additional Reading

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!