PHPPHP Introduction

PHP Introduction

PHP is a server-side scripting language built specifically for the web. You write a .php file, a server runs it, and the server sends the result — usually HTML, sometimes JSON — back to whoever asked for it. The visitor's browser never sees a line of PHP; it only ever sees what the script produced. That single idea, generate output on the server before the page ever reaches the browser, is the reason PHP has powered a huge share of the web for three decades and still touches a majority of websites with a known server-side language today.

This series assumes no prior PHP experience, but it does not waste your time on toy examples that fall apart the moment you try to build something real. Each page pairs a concept with working, modern PHP 8.x code you can paste into a file and run immediately.

A quick taste

Here is a complete, runnable PHP script. Save it as hello.php and run it with the built-in development server (php -S localhost:8000) or any PHP-enabled web server.

hello.php

PHP
<?php

$visitor = 'there';
$hour = (int) date('H');

$greeting = match (true) {
    $hour < 12 => 'Good morning',
    $hour < 18 => 'Good afternoon',
    default    => 'Good evening',
};

echo "{$greeting}, {$visitor}! The server time is " . date('H:i:s') . '.';
Good afternoon, there! The server time is 14:32:07.

Notice what happened: the match expression, the date() calls, and the string interpolation all ran on the server. The browser only ever receives the finished sentence — no PHP syntax, no server clock logic, just plain text (or HTML, if you echo tags too).

Where PHP actually shows up today

PHP is not a relic kept alive by legacy systems. It is under active, well-funded development and sits at the core of software you almost certainly use:

  • WordPress — powers a large share of all websites on the internet, and it is written entirely in PHP, as are most of its themes and plugins.

  • Laravel and Symfony — modern, full-featured frameworks used to build APIs, SaaS products, and enterprise applications with the same conventions and tooling quality developers expect from any other ecosystem.

  • E-commerce — platforms like WooCommerce (built on WordPress) and Magento run a substantial portion of the world's online stores.

  • High-traffic platforms — Wikipedia, large parts of Facebook's original stack (which inspired the HHVM runtime), Slack's early backend, and countless SaaS companies either run PHP today or grew out of it.

  • APIs and internal tooling — PHP is a common, pragmatic choice for REST/JSON backends, admin panels, and content-management systems built by small teams that need to ship fast.

What this tutorial series covers

The goal is to take you from "what even is PHP" to writing confident, idiomatic PHP 8 code. Broadly, the series is organized into a few arcs:

  • Foundations — what PHP is, how a request actually flows from browser to server and back, and the history behind the language's design decisions.

  • Language basics — variables, types, operators, control structures, functions, and PHP's particular flavor of arrays.

  • Object-oriented PHP — classes, interfaces, traits, and the object model that modern frameworks like Laravel and Symfony are built on.

  • Working with data — strings, dates, files, and talking to databases safely.

  • Modern PHP practices — Composer, namespaces, autoloading, error handling, and the language features introduced in PHP 7 and 8 that make the language feel genuinely current.

Why PHP is still relevant in 2026

Three things keep PHP central to web development rather than fading into legacy status. First, the runtime itself has changed dramatically: PHP 8 shipped a JIT compiler, union and named arguments, enums, readonly properties, and a much stricter type system — this is not the PHP of 2005. Second, the ecosystem is mature: Composer for dependency management, PSR standards for interoperability, and frameworks like Laravel that rival anything available in other languages for developer experience. Third, distribution — PHP already runs the content-management systems and e-commerce platforms behind a massive slice of the live web, which means PHP skills stay in continuous demand for maintenance, upgrades, and new feature work on systems that are not going anywhere.

You do not need to install anything exotic
PHP ships a built-in development server (`php -S localhost:8000`), so you can follow along on this site with nothing more than the PHP CLI installed. You do not need Apache, Nginx, or a database to run the early examples in this series.
Tip
As you work through this series, actually run every example instead of just reading it. PHP's error messages (especially in PHP 8, which made many former warnings into thrown exceptions) are one of the fastest ways to build an accurate mental model of how the language behaves.