What is PHP?

Tech By 1 min read

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

  1. You visit a page, such as a blog post.
  2. The server runs the PHP code, which might fetch the post from a database.
  3. PHP builds an HTML page and sends it to your browser.
  4. 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

PHPJavaScript
Runs mainly onThe serverThe browser (and servers with Node.js)
Typical jobBuilding pages, talking to databasesMaking pages interactive
Used together?Often, on the same websiteOften, 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.

Surprise me

Keep exploring