If you've ever looked at the files of a WordPress site, you've seen dozens of files ending in .php. You may have also seen a setting in your hosting control panel for choosing a "PHP version." So what is PHP, and why should a website owner care?
This guide explains PHP in plain language: what it does, how it works on a web server and the practical things you need to know to keep a PHP site healthy.
PHP in a nutshell
PHP is a programming language that runs on the web server and generates web pages before they're sent to the visitor's browser. The name is a recursive acronym for "PHP: Hypertext Preprocessor," which hints at its job: processing things before the browser sees them.
PHP has been around since the mid-1990s and is one of the most widely used server-side languages on the web. It powers popular content management systems including WordPress, Joomla and Drupal, e-commerce platforms such as WooCommerce and Magento, and frameworks like Laravel and Symfony.
Server-side vs client-side
To understand PHP, it helps to know the difference between two places code can run:
- Client-side code runs in the visitor's browser. HTML, CSS and JavaScript are the main examples. The visitor's device does the work, and anyone can view the code.
- Server-side code runs on the web server. PHP is server-side. The visitor never sees the PHP code itself, only the HTML it produces.
That's an important point: when you "view source" on a WordPress page, you see HTML, not PHP. The PHP ran on the server and finished its job before the page arrived.
How PHP works when someone visits your site
- A visitor requests a page, such as
example.com/contact/. - The web server sees that the request should be handled by a PHP file.
- PHP runs the code in that file. It might read settings, query a database, check whether the visitor is logged in and fill in a template.
- PHP outputs plain HTML.
- The server sends that HTML to the visitor's browser.
A tiny example
<!DOCTYPE html>
<html>
<body>
<h1>Welcome!</h1>
<p>Today is <?php echo date('l, F j, Y'); ?>.</p>
</body>
</html>
The part inside <?php ... ?> runs on the server. The visitor receives something like "Today is Monday, March 2, 2026" in plain HTML. Every day the page shows the current date without anyone editing it.
What PHP is used for
- Building pages from a database. WordPress stores posts in a database and uses PHP to fetch and display them.
- Handling forms. Contact forms, signups and checkouts send data to PHP, which validates it, stores it or emails it.
- User accounts and sessions. Logging in, staying logged in and seeing your own dashboard.
- Reusable layouts. One header file included on every page.
- Talking to other services. Payment gateways, shipping calculators and email services through their APIs.
- Scheduled tasks. PHP scripts run by cron jobs to send reminders or clean up old data.
Why so many sites use PHP
- It's available almost everywhere. Practically every shared hosting plan supports PHP out of the box.
- It's easy to start. You can drop a
.phpfile into your hosting account and it runs; there's no complicated build or deploy step. - Huge ecosystem. Decades of tutorials, libraries, plugins and community support.
- Modern PHP is fast and capable. Recent versions brought big performance gains and modern language features compared to the old releases many people remember.
PHP versions: why they matter
PHP is updated regularly. Each major version gets a period of active support followed by security-only fixes, and then it reaches end of life, meaning no more security patches.
Running an outdated version can lead to:
- Security risks from unpatched vulnerabilities
- Slower performance, since newer versions are generally faster
- Plugin and theme incompatibility, as developers drop support for old versions
Most hosting control panels let you choose a PHP version per site. Before switching, it's wise to:
- Take a full backup of your files and database.
- Check that your CMS, theme and plugins support the newer version.
- Test on a staging copy if you can.
- Switch, then browse key pages, forms and checkout to confirm everything works.
- Switch back if something breaks, and fix the incompatible component.
The official php.net website lists which versions are currently supported.
PHP settings website owners should know
Your host usually lets you adjust a few PHP settings, often through a control panel tool or a php.ini or .user.ini file. Common ones:
- memory_limit sets how much memory a single script can use. Heavy plugins or page builders may need more.
- upload_max_filesize and post_max_size control how large an uploaded file can be, which matters for big images, videos or importing backups.
- max_execution_time sets how long a script can run before it's stopped. Imports and backups sometimes need longer.
- display_errors controls whether errors show on the page. Keep it off on a live site so visitors (and attackers) don't see internal details; log errors instead.
PHP and databases
PHP is most often paired with MySQL or its close relative MariaDB. PHP sends queries to the database ("give me the five latest posts") and turns the results into HTML. This combination, often running on Linux with Apache, Nginx or LiteSpeed, is one of the most common setups on the web.
Security basics for PHP sites
You don't need to write PHP to keep a PHP site safe. Focus on these habits:
- Keep your CMS, plugins and themes updated.
- Remove plugins and themes you don't use.
- Use a supported PHP version.
- Use strong, unique passwords for admin accounts and the database.
- Don't upload random PHP scripts from untrusted sources.
- Keep regular, tested backups.
If you do write PHP, learn about validating input, escaping output and using prepared statements for database queries. These three habits prevent many common vulnerabilities.
Should you learn PHP?
If you run a WordPress site and want to customize themes, build small plugins or understand error messages, learning basic PHP is very worthwhile. It's also a practical first server-side language because you can test it on almost any hosting account. If you're more interested in front-end design, start with HTML, CSS and JavaScript first.
Wrapping up
PHP is the server-side language that turns code and database content into the HTML pages your visitors see. It powers WordPress and much of the web, runs on nearly every hosting plan and is easy to get started with. For website owners, the key takeaways are simple: keep PHP on a supported version, know a few key settings and keep your PHP-based software up to date.