What is PHP?
Quick answer
PHP is a server-side programming language used to build dynamic websites. It runs on the web server, creates the HTML page, and sends it to your browser. It powers WordPress and a large share of all websites. The name stands for “PHP: Hypertext Preprocessor.”
PHP was created by Rasmus Lerdorf in 1994, originally as a set of tools to track visitors to his online résumé. It grew into one of the most widely used languages on the web.
How PHP works
- You visit a page, such as a blog post.
- The server runs the PHP code, which might fetch the post from a database.
- PHP builds an HTML page and sends it to your browser.
- Your browser only sees the finished HTML, never the PHP code.
A tiny example:
<?php
$name = "World";
echo "<h1>Hello, $name!</h1>";
?>
What PHP is used for
- Content management systems: WordPress, Drupal, Joomla
- Online stores: WooCommerce, Magento
- Web apps built with frameworks like Laravel and Symfony
- Handling forms, logins and databases
PHP vs JavaScript
| PHP | JavaScript | |
|---|---|---|
| Runs mainly on | The server | The browser (and servers with Node.js) |
| Typical job | Building pages, talking to databases | Making pages interactive |
| Used together? | Often, on the same website | Often, on the same website |
Pros and cons
Pros: easy to start with, supported by almost every web host, huge community, and modern versions (PHP 8 and later) are much faster than older ones. Cons: older code bases can be messy and inconsistent, and many newer projects choose JavaScript, Python or Go instead.
Want to try it? See how to learn coding online and how to start a blog, since many blogs run on PHP-based WordPress.
Still curious?
Jump to a random question from the archive.