PHP is the server-side programming language that most website software, including WordPress, is written in.
PHP is a programming language that runs on the web server rather than in the visitor's browser. When someone opens a page, the server runs the PHP code, which might read from a database, check whether the visitor is logged in and fill in a template. The result is plain HTML, and that's all the browser ever sees.
WordPress, Drupal, Joomla, Magento, Laravel and most other popular CMS platforms and frameworks are written in PHP. That's why almost every web hosting plan supports it.
How PHP works on a web server
- A visitor requests a page, such as
/shop/. - The web server, for example LiteSpeed or Apache, hands the request to PHP.
- PHP runs your application's code, often querying a MySQL database.
- PHP returns the finished HTML to the web server, which sends it to the visitor.
Each request is handled by a PHP worker. To avoid reading and compiling the same code every time, PHP's OPcache keeps compiled code in memory, which makes a big difference to speed.
Why your PHP version matters
PHP is released in versions, and each one is supported for a limited time. Newer versions are usually faster and include security fixes that older ones no longer get. Once a version reaches end of life, it stops receiving security patches, which leaves sites running on it more exposed to attack.
Choosing a version is a balance:
- Too old and you miss performance gains and security fixes.
- Too new and an old plugin or theme might not be compatible yet.
Most up-to-date WordPress sites run well on current PHP 8 releases. Check your plugins' and theme's requirements before switching.
How to change your PHP version
On most hosts you can pick a PHP version in the control panel, often per domain, through a tool like cPanel's PHP Selector or MultiPHP Manager. Before you switch:
- Take a backup, or test on a staging site.
- Update WordPress, plugins and themes.
- Switch the version and check key pages, forms and checkout.
- If something breaks, switch back and look at the error log to find the cause.
AblePage lets you choose any version from PHP 8.1 to 8.4.
Common PHP errors
- White screen or "critical error": usually a fatal error in a plugin or theme. The error log shows which file.
- Memory exhausted: the script needs more than the
memory_limitsetting allows. - Maximum execution time exceeded: a script ran longer than
max_execution_time. - Deprecated warnings after an upgrade, which mean code needs updating before the next version.