It is important to know which PHP version is working behind the scenes of your WordPress website–it affects available features, performance, and updates. In this quick tutorial I will show you two ways to find out the WordPress PHP version.
Before that, let’s quickly talk about why it is important, what PHP actually is, and how it relates to WordPress.
What is PHP?
“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.” — php.net
PHP is a programming language that first appeared back in in 1995. Rasmus Lerdorf created it for making dynamic websites.
PHP is short for “PHP Hypertext Preprocessor” (though it was once known affectionately as “Personal Home Page” tools) and is what’s called a “server-side language”. This means the code is executed on the server and sends the result to the client-side or the browser.
Some examples of server-side functions:
- creating data
- reading data
- updating data
- deleting data
- using databases
- logging feature
- login feature
- parsing among data formats
- generate dynamic websites
Some features of PHP:
- free to use
- has extension ".php"
- PHP files can contain HTML, CSS, JavaScript, and PHP code as well
- multi-paradigm: functional, object-oriented, and procedural too
- the typing system is also multi-faceted: dynamic, weak, gradual
- implemented in C language
- ability to create static and dynamic webpages
Example PHP Code
This is an example of some PHP code embedded into HTML (note the <?php ?>
tag):
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <?php echo "Hello World!"; ?> </body> </html>
The result of this code is that a statement is echoed (or output):
Hello World!
Example PHP Code 2
We can use PHP to output other things too, such as information about the PHP server itself:
<?php phpinfo(); ?>
This will output lots of data. Here’s a small extract:
Extract | ||
PHP Version | 7.4.16 | |
System | Windows NT DESKTOP-93A9AT6 10.0 build 19041 (Windows 10) AMD64 | |
Build Date | Mar 2 2021 13:58:29 |
Advantages of PHP
PHP has all kinds of things going for it as a dynamic language/server technology:
- multi-platform:
- Windows,
- Linux,
- Unix,
- Mac OS
- free to use
- easy to learn and advanced features for advanced programmers
- multiple supported databases:
- MySQL
- PostgreSQL
- Sybase
- IBM-DB2
- Oracle Database
- Mongo
- SQLite and many others...
- good online support and community
- unit testing is available
- built-in security features like variable filtering and solutions against SQL injection
PHP and WordPress
PHP is the only backend language for WordPress. It is used for the engine, templates, and plugins.
PHP Version Support in WordPress
The latest version of WordPress at the time of writing (May 2021) is v5.7 which supports the following PHP versions:
- 5.6 (this old version may expose the website to security issues)
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0
The recommended PHP version for WordPress is 7.x or 8.x. In 7.x there was a major performance improvement compared to 5.x. (And v6 was never released.)
Actual PHP Versions
Usually, the latest stable PHP version is recommended for use. The reasons being:
- new features
- development lifecycle (2 years of support per version)
- security updates
- performance improvements
The latest PHP versions at the time (May 2021) of this article are:
- 7.3.28
- 7.4.19
- 8.0.6
How to Check the WordPress PHP Version
If you have admin rights, you can go to the WordPress admin interface and choose: Tools > Site Health > Info / Server.
Example Result
You’ll see something like this, showing that the PHP version is (in this case) 7.4.16:
Extract | |||
Server architecture | Windows NT 10.0 AMD64 | ||
Web server | Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/7.4.16 | ||
PHP version | 7.4.16 (Supports 64bit values) | ||
PHP SAPI | apache2handler | ||
PHP max input variables | 1000 |
Display the WordPress PHP Version in the Footer
It’s possible to display the PHP version at all times in the admin footer. This will save you having to navigate to the Tools page to search for the information yourself. It’s done with a free plugin called Version Info.
In your WordPress admin go to Plugins > Add New and search for “Version Info”.
Install and activate the plugin, and you’ll see information about the WordPress version, the PHP version, and MySQL version in the admin footer at all times:
Summary
In this short tutorial, we learned what is PHP, the current available versions, and two ways to check the current version being used by your installation of WordPress. Remember: it is important to upgrade to the latest PHP version recommended by WordPress.
Make sure to check the Requirements section on WordPress.org.
No comments:
Post a Comment