PHP

A widely-used server-side scripting language powering a large portion of the web, including WordPress.

Object-Oriented
Procedural
Functional
Beginner
1995
Rasmus Lerdorf

Overview

PHP is a general-purpose scripting language especially suited to web development. It powers over 75% of websites whose server-side language is known, including WordPress, Wikipedia, and Facebook. Modern PHP (8.x) has evolved significantly with typed properties, match expressions, fibers, enums, and readonly classes.

Key Features

  • Web-native — Built specifically for server-side HTML generation
  • Modern type system — Union types, intersection types, enums (PHP 8.x)
  • Composer — Mature dependency manager with Packagist repository
  • Frameworks — Laravel, Symfony, and many more
  • Massive deployment — Runs on virtually any hosting provider

Code Example

php
<?php
enum Status: string {
    case Active = 'active';
    case Inactive = 'inactive';
}

readonly class User {
    public function __construct(
        public string $name,
        public string $email,
        public Status $status = Status::Active,
    ) {}
}

$user = new User('Alice', 'alice@example.com');
echo match($user->status) {
    Status::Active => "Welcome, {$user->name}!",
    Status::Inactive => "Account disabled.",
};

Learning Resources

Learning Path

15 topics across 4 sections

1Basics

  • Introduction to PHP — PHP tags, embedding in HTML, and server-side execution
  • Variables & Types — Dynamic typing, type juggling, strict_types, and constants
  • Strings & Arrays — String functions, array functions, and array manipulation
  • Control Flow — if/elseif, switch, match (8.0+), for, foreach, while
  • Functions — Named and anonymous functions, closures, arrow functions (fn)

2OOP

3Web & Database

  • Forms & Sessions — $_GET, $_POST, sessions, cookies, and CSRF protection
  • PDO & Database — Prepared statements, transactions, and database abstraction
  • REST APIs — JSON handling, request routing, and API design

4Frameworks & Ecosystem

  • Composer — Dependency management, autoloading, and Packagist
  • Laravel — Routing, Eloquent ORM, Blade templates, and middleware
  • Testing — PHPUnit, Pest, mocking, and code coverage