PHP Fundamentals Course: The Basics of PHP 8 for the Web

PHP Fundamentals is a beginner-level course of 5 lessons (about 2 h 26 min), with 15 exercises and 15 quiz questions. Prerequisites: Programming Basics and Algorithms. Exercises are run and checked in a server-side sandbox.

  • PHP
  • Beginner
  • 5 lessons
  • 2 h 26 min
  • 15 exercises
  • Exercises run in a server sandbox

The course in brief

This course lays the foundations of modern PHP web development. You write typed scripts, work with data arrays, build reusable functions, then handle a web form while validating input and protecting yourself against XSS. Each lesson alternates short explanations with automatically run exercises.

What you will be able to do

  • Write and run PHP 8.5 scripts from the command line and with the built-in server
  • Work with variables, strings, conditions, match and loops
  • Process lists of data with associative arrays and array_* functions
  • Design typed functions with strict_types, default values and named arguments
  • Read, validate and safely redisplay the data of a web form

Syllabus: 5 lessons

    • Write and run a first PHP script from the command line
    • Declare variables and tell the scalar types apart (int, float, string, bool, null)
    • Build strings by concatenation and by interpolation

    Basic syntaxVariables and typesStrings

  1. 02

    Conditions, match and Loops

    15 min
    • Write conditions with if / elseif / else and logical operators
    • Use the match expression and the null coalescing operator ??
    • Repeat processing with for, while and foreach

    ConditionsThe match expressionLoops

  2. 03

    Indexed and Associative Arrays

    18 min
    • Create and manipulate indexed, associative and nested arrays
    • Iterate over an array with foreach, retrieving keys and values
    • Transform data with array_map, array_filter, array_column and array_sum

    ArraysIterating with foreachArray functions

  3. 04

    Typed and Reusable Functions

    18 min
    • Declare functions with parameters and a return type
    • Enable strict typing and use nullable types, unions and default values
    • Use named arguments, variadic parameters and anonymous functions

    FunctionsTyping and strict_typesAnonymous and arrow functions

  4. 05

    PHP and the Web: Forms and Basic Security

    20 min
    • Understand the request / response cycle of a PHP page
    • Read form data with $_GET and $_POST and validate it
    • Protect the output against XSS vulnerabilities with htmlspecialchars

    The $_GET and $_POST superglobalsInput validationHTML escaping (XSS)

Final project

Quote Simulator for a Craftsperson

Build a small PHP application without a framework: a page presents three services (associative array), a form lets you choose a service, a quantity and enter a name and email. The script validates the inputs, computes the quote (excl. tax, VAT, incl. tax, discount above a threshold) with typed functions and displays an escaped summary. Errors are redisplayed in the form.

Deliverables

  • A project folder with index.php, a fonctions.php file (included with require) and merci.php
  • Typed functions with strict_types: quote calculation, price formatting, form validation, escaping
  • A README file explaining how to run the project with php -S

Assessment criteria

  • The excl. tax, VAT, discount and incl. tax calculations are accurate and correctly rounded
  • All inputs are validated server-side, with clear messages per field
  • All displayed data is escaped with htmlspecialchars
  • The code is organized into reusable typed functions, without duplication
  • The Post/Redirect/Get pattern is applied after a valid submission

Frequently asked questions

Do I need to know HTML before learning PHP?

Basic programming knowledge is enough to get started (variables, conditions, loops). Knowing HTML helps for the last lesson on forms, but the useful concepts are recalled there.

Which PHP version is used?

The course uses PHP 8.5 and modern practices: strict typing, the match expression, named arguments, arrow functions, as well as the pipe operator |> and array_first() / array_last() introduced in PHP 8.5.

Is PHP still used in 2026?

Yes. PHP powers a large share of websites, notably through WordPress, Laravel and Symfony, and remains in high demand for back-end developer positions.

Do I need to install anything?

Not for the exercises: they run directly in your browser. For the hands-on task on forms, a local PHP 8.5 installation lets you use the built-in php -S server.

This course, told for your job

Say what you want to be able to do: “PHP Fundamentals” takes its place in your path, with examples from your field. The concepts stay those of the course.

The preview is free, and you can take the courses one at a time without paying. The path only contains lessons from the catalogue.