The PHP path · 100 lessons · 8 stages
One concept. One working program.
Go in order, or jump to what you need. Each lesson takes about ten minutes and ends with an exercise you check in your browser.
Stage 1 · Lessons 1–13
Foundations
Variables, types, operators, conditions, strings, arrays, loops and functions.
Stage 1 · Lessons 1–13
Foundations
Variables, types, operators, conditions, strings, arrays, loops and functions.
- 01Your First PHP ProgramGetting started12 min
- 02PHP Variables: Store and Reuse ValuesVariables12 min
- 03PHP Scalar Types: Strings, Integers, Floats and BooleansTypes12 min
- 04PHP Operators: Calculate and CompareOperators12 min
- 05PHP Conditionals: Choose a BranchControl flow12 min
- 06PHP Strings: Your First GreetingStrings10 min
- 07PHP String Functions: Clean and Transform TextStrings12 min
- 08PHP Arrays: Read and Update a ListArrays10 min
- 09PHP Associative Arrays: Work with Named KeysArrays12 min
- 10PHP Loops: Add Numbers with foreachLoops12 min
- 11PHP while Loops: Repeat Until a Condition ChangesLoops12 min
- 12PHP Functions: Return a Calculated ValueFunctions12 min
- 13PHP Function Arguments: Defaults and Named CallsFunctions12 min
Stage 2 · Lessons 14–19
Functions and types
Type declarations, closures, arrow functions, null handling and exceptions.
Stage 2 · Lessons 14–19
Functions and types
Type declarations, closures, arrow functions, null handling and exceptions.
- 14PHP Type Declarations: Make Function Contracts ClearTypes12 min
- 15PHP Closures: Capture Values from the Surrounding ScopeFunctions12 min
- 16PHP Arrow Functions: Express a Small TransformationFunctions12 min
- 17PHP Array Transformations: Map and Filter ValuesArrays12 min
- 18PHP Null and Defaults: Handle Missing ValuesTypes12 min
- 19PHP Exceptions: Handle Errors ExplicitlyErrors12 min
Stage 3 · Lessons 20–25
Objects
Classes, constructors, inheritance, interfaces, traits and enums.
Stage 3 · Lessons 20–25
Objects
Classes, constructors, inheritance, interfaces, traits and enums.
- 20PHP Classes: Create and Use an ObjectClasses12 min
- 21PHP Constructors and Properties: Initialize an ObjectClasses12 min
- 22PHP Inheritance: Extend a Small ClassClasses12 min
- 23PHP Interfaces: Program to a ContractClasses12 min
- 24PHP Traits: Reuse a Small Piece of BehaviorClasses12 min
- 25PHP Enums: Represent a Fixed Set of ChoicesClasses12 min
Stage 4 · Lessons 26–30
Working with data
JSON, input validation, regular expressions, dates and namespaces.
Stage 4 · Lessons 26–30
Working with data
JSON, input validation, regular expressions, dates and namespaces.
- 26PHP JSON: Encode and Decode Structured DataJSON12 min
- 27PHP Input Validation: Check Before Using a ValueValidation12 min
- 28PHP Regular Expressions: Match a Simple PatternRegular expressions12 min
- 29PHP DateTimeImmutable: Work with Fixed DatesDates12 min
- 30PHP Namespaces: Organize Related ClassesOrganization12 min
Stage 5 · Lessons 31–39
Strings in depth
Formatting, searching, replacing, padding and escaping output safely.
Stage 5 · Lessons 31–39
Strings in depth
Formatting, searching, replacing, padding and escaping output safely.
- 31String Interpolation and ConcatenationStrings15 min
- 32Find Text with strpos and str_containsStrings15 min
- 33Slice Strings with substrStrings15 min
- 34Replace Text with str_replaceStrings15 min
- 35Split and Join StringsStrings15 min
- 36Format Values with sprintfStrings15 min
- 37Pad and Repeat StringsStrings15 min
- 38Escape Text for HTML OutputSecurity15 min
- 39Encode URL ComponentsStrings15 min
Stage 6 · Lessons 40–59
Control flow and arrays in depth
Strict comparisons, match, loop control, sorting, grouping and sets.
Stage 6 · Lessons 40–59
Control flow and arrays in depth
Strict comparisons, match, loop control, sorting, grouping and sets.
- 40Numeric Strings and Explicit ConversionTypes15 min
- 41Strict Comparisons and Type JugglingTypes15 min
- 42Return Values with match ExpressionsControl flow15 min
- 43Choose Branches with switchControl flow15 min
- 44Break and Continue in LoopsLoops15 min
- 45Work with Nested LoopsLoops15 min
- 46Navigate Multidimensional ArraysArrays15 min
- 47Work with Array Keys and ValuesArrays15 min
- 48Search Arrays with Strict MembershipArrays15 min
- 49Sort Array Values PredictablyArrays15 min
- 50Sort Associative ArraysArrays15 min
- 51Write Custom Array ComparatorsArrays15 min
- 52Slice and Splice ArraysArrays15 min
- 53Merge Arrays and Replace KeysArrays15 min
- 54Compare Arrays as SetsArrays15 min
- 55Remove Duplicate Array ValuesArrays15 min
- 56Group Records by a Shared KeyArrays15 min
- 57Chunk Data into BatchesArrays15 min
- 58Aggregate Records with array_reduceArrays15 min
- 59Combine Related ArraysArrays15 min
Stage 7 · Lessons 60–83
Functions, types and classes in depth
Recursion, references, union types, readonly classes and composition.
Stage 7 · Lessons 60–83
Functions, types and classes in depth
Recursion, references, union types, readonly classes and composition.
- 60Accept Variable ArgumentsFunctions15 min
- 61Unpack Function ArgumentsFunctions15 min
- 62Call Functions with Named ArgumentsFunctions15 min
- 63Understand Pass by ReferenceFunctions15 min
- 64Solve Small Problems with RecursionFunctions15 min
- 65Build Predictable Pure FunctionsFunctions15 min
- 66Pass Behavior into Higher-Order FunctionsFunctions15 min
- 67Capture Values in ClosuresFunctions15 min
- 68Model Alternatives with Union TypesTypes15 min
- 69Require Multiple Interfaces with Intersection TypesTypes15 min
- 70Design Nullable Function ContractsTypes15 min
- 71Use Strict Scalar Type CheckingTypes15 min
- 72Navigate Optional Objects with Nullsafe CallsClasses15 min
- 73Control Property VisibilityClasses15 min
- 74Protect Values with Readonly PropertiesClasses15 min
- 75Create Readonly Value ObjectsClasses15 min
- 76Use Static Methods and ConstantsClasses15 min
- 77Name Domain Values with Class ConstantsClasses15 min
- 78Share Contracts with Abstract ClassesClasses15 min
- 79Compose Objects from Smaller BehaviorsClasses15 min
- 80Inject Object DependenciesClasses15 min
- 81Build Small Value ObjectsClasses15 min
- 82Clone Objects DeliberatelyClasses15 min
- 83Give Objects a String RepresentationClasses15 min
Stage 8 · Lessons 84–100
Modern PHP in practice
Enums, error handling, JSON, iterators, generators and reflection.
Stage 8 · Lessons 84–100
Modern PHP in practice
Enums, error handling, JSON, iterators, generators and reflection.
- 84Control Object JSON SerializationJSON15 min
- 85Map External Values to Backed EnumsEnums15 min
- 86Attach Behavior to Enum CasesEnums15 min
- 87Define Domain-Specific ExceptionsErrors15 min
- 88Guarantee Cleanup with finallyErrors15 min
- 89Handle JSON Failures ExplicitlyJSON15 min
- 90Validate JSON Before DecodingJSON15 min
- 91Extract Values with Regex CapturesRegular expressions15 min
- 92Transform Text with Regex CallbacksRegular expressions15 min
- 93Normalize Inputs Before ValidationValidation15 min
- 94Build and Parse Query StringsHTTP concepts15 min
- 95Calculate with DateTimeImmutableDates15 min
- 96Add and Compare Date IntervalsDates15 min
- 97Yield Values with GeneratorsIteration15 min
- 98Implement a Simple IteratorAggregateIteration15 min
- 100Read Metadata with PHP AttributesReflection15 min
Every example and exercise check is executed on the browser runtime before a lesson is published. Spotted a mistake? Each lesson has a report link. Looking for a single function? Open the PHP reference →