Skip to content
Pebellslearn by building

The course

PHP

Learn how PHP runs on the server and turns code into web pages. You will work with variables, types, arrays, decisions, functions and loops, then read URLs and forms safely — all while building a small online bookshop.

Ready to learn

Your path through the ideas

Inside the course

7 modules · 23 lessons
CLI tools & setup · Start here

Install your tools, choose your setup and verify a local run.

02Introduction to PHP4 lessons

PHP is a programming language often used on a web server to process requests and produce responses. See where PHP runs and where it came from, learn its basic writing rules, and understand how variables, scope, types and casting behave.

  1. 01What PHP Is and Where It Came From12 min
  2. 02Basic PHP Syntax12 min
  3. 03Variables and Scope14 min
  4. 04Data Types and Casting15 min
03Output and Arrays4 lessons

Output sends information to a response or console. A PHP array is an ordered map that can use integer and string keys. Choose between echo, print, var_dump and print_r, then store data in indexed, associative and multi-dimensional arrays.

  1. 01Printing Values: echo, print, var_dump, print_r12 min
  2. 02Indexed Arrays12 min
  3. 03Associative Arrays13 min
  4. 04Multi-dimensional Arrays15 min
04Conditionals4 lessons

A conditional selects behavior based on a test, a matching case or whether a value is absent. Choose the right branch with if and elseif, compare one value against many with switch and match, and handle missing values with ?? and ?->.

  1. 01if, elseif and else12 min
  2. 02switch12 min
  3. 03match13 min
  4. 04The Null Operators: ?? and ?->14 min
05Functions5 lessons

A function packages reusable behavior with parameters and a return value. Constants name values that cannot be reassigned. Define constants, write typed functions with parameters and return values, use defaults and named arguments, pass functions as callbacks, and write recursive and variadic functions.

  1. 01Constants11 min
  2. 02Declaring Functions: Parameters and Return Values13 min
  3. 03Default Values and Named Arguments13 min
  4. 04Anonymous, Callback and Arrow Functions15 min
  5. 05Recursion and Variadic Functions15 min
06Loops and Includes3 lessons

A loop repeats instructions. Including a file loads and evaluates that file as part of the current PHP program. Repeat actions with while, do-while and for, walk arrays with foreach, and split a site into shared files with include and require.

  1. 01while, do-while and for13 min
  2. 02foreach13 min
  3. 03include, require and the _once Versions14 min
07HTTP Methods and Forms3 lessons

HTTP methods describe request semantics. Form and request data arrive as external input that PHP must validate before use. Read query strings with $_GET, handle forms with $_POST using a safe method-validate-act-redirect recipe, and understand $_REQUEST and $_SERVER.

  1. 01$_GET — Reading the Query String13 min
  2. 02$_POST and Processing a Form16 min
  3. 03$_REQUEST and $_SERVER13 min
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.