World Class Learning • Free Open Education for Students & Teachers
Home Verbs (2,516) Modal Verbs 12 Tenses 4k Words Idioms Worksheets
Computer Programming

Learn PHP: From PHP 5 to Modern PHP 8

Complete guide to server-side scripting, superglobals, and secure form processing.

Web Development Guide Updated for Modern PHP 8.x

PHP 5 & PHP 6 Tutorial: Architecture, Superglobals & Modern PHP 8.x

PHP powers over 75% of the web's server-side applications, including WordPress, Wikipedia, and major web platforms. Below is the classic foundation tutorial covering core syntax, Superglobals, HTML form processing, and the famous history of why PHP 6 was abandoned in favor of PHP 7 and modern PHP 8.x.

💡

Historical Trivia: What Happened to PHP 6?

Back in 2005–2008, PHP 6 was developed to bring native Unicode UTF-16 support into the PHP core. However, the conversion created severe performance degradation and memory bottlenecks. The PHP development team officially cancelled the PHP 6 project, backported useful features into PHP 5.3/5.4, and later skipped directly to PHP 7 (delivering a 200% speed increase via the Zend Engine 3) and today's PHP 8.x (with JIT compilation).

1. Understanding PHP Superglobals

Built-in global arrays available in all scopes without the 'global' keyword.

$_GET

Collects data submitted through HTTP GET methods via URL query parameters (e.g. page.php?id=10). Parameters are visible in the browser address bar.

$_POST

Collects data submitted invisibly in the HTTP request body through HTML forms using method="post" (passwords, registration data).

$_SESSION

Stores user variables across multiple pages during a visit. Requires calling session_start() at the top of the script.

$_SERVER

Contains server and execution environment information (e.g. $_SERVER['REQUEST_METHOD'], $_SERVER['HTTP_HOST']).

2. How to Process an HTML Form in PHP

The clean, secure pattern to handle form inputs with sanitization:

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Sanitize user inputs to prevent XSS attacks
    $name = htmlspecialchars(trim($_POST['username']));
    $email = filter_var(trim($_POST['email']), FILTER_SANITIZE_EMAIL);

    if (!empty($name) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
        echo "Welcome, " . $name . "! Your email has been verified.";
    } else {
        echo "Please provide a valid name and email address.";
    }
}
?>

Key Modern PHP (PHP 8.x) Advancements

  • JIT (Just-In-Time) Compiler: Compiles machine code at runtime for high-performance CPU-intensive tasks.
  • Named Arguments: Pass values into a function by specifying the parameter name (createUser(name: 'Aditi', role: 'admin')).
  • Match Expressions: A modern, strictly-typed alternative to the old switch statement.
  • Constructor Property Promotion: Reduces boilerplate when defining classes and object-oriented properties.