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.

99lessons available
Start with lesson 01

Stage 1 · Lessons 1–13

Foundations

Variables, types, operators, conditions, strings, arrays, loops and functions.

13 of 13 published
  1. 01Your First PHP ProgramGetting started12 min
  2. 02PHP Variables: Store and Reuse ValuesVariables12 min
  3. 03PHP Scalar Types: Strings, Integers, Floats and BooleansTypes12 min
  4. 04PHP Operators: Calculate and CompareOperators12 min
  5. 05PHP Conditionals: Choose a BranchControl flow12 min
  6. 06PHP Strings: Your First GreetingStrings10 min
  7. 07PHP String Functions: Clean and Transform TextStrings12 min
  8. 08PHP Arrays: Read and Update a ListArrays10 min
  9. 09PHP Associative Arrays: Work with Named KeysArrays12 min
  10. 10PHP Loops: Add Numbers with foreachLoops12 min
  11. 11PHP while Loops: Repeat Until a Condition ChangesLoops12 min
  12. 12PHP Functions: Return a Calculated ValueFunctions12 min
  13. 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.

6 of 6 published
  1. 14PHP Type Declarations: Make Function Contracts ClearTypes12 min
  2. 15PHP Closures: Capture Values from the Surrounding ScopeFunctions12 min
  3. 16PHP Arrow Functions: Express a Small TransformationFunctions12 min
  4. 17PHP Array Transformations: Map and Filter ValuesArrays12 min
  5. 18PHP Null and Defaults: Handle Missing ValuesTypes12 min
  6. 19PHP Exceptions: Handle Errors ExplicitlyErrors12 min

Stage 3 · Lessons 20–25

Objects

Classes, constructors, inheritance, interfaces, traits and enums.

6 of 6 published
  1. 20PHP Classes: Create and Use an ObjectClasses12 min
  2. 21PHP Constructors and Properties: Initialize an ObjectClasses12 min
  3. 22PHP Inheritance: Extend a Small ClassClasses12 min
  4. 23PHP Interfaces: Program to a ContractClasses12 min
  5. 24PHP Traits: Reuse a Small Piece of BehaviorClasses12 min
  6. 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.

5 of 5 published
  1. 26PHP JSON: Encode and Decode Structured DataJSON12 min
  2. 27PHP Input Validation: Check Before Using a ValueValidation12 min
  3. 28PHP Regular Expressions: Match a Simple PatternRegular expressions12 min
  4. 29PHP DateTimeImmutable: Work with Fixed DatesDates12 min
  5. 30PHP Namespaces: Organize Related ClassesOrganization12 min

Stage 5 · Lessons 31–39

Strings in depth

Formatting, searching, replacing, padding and escaping output safely.

9 of 9 published
  1. 31String Interpolation and ConcatenationStrings15 min
  2. 32Find Text with strpos and str_containsStrings15 min
  3. 33Slice Strings with substrStrings15 min
  4. 34Replace Text with str_replaceStrings15 min
  5. 35Split and Join StringsStrings15 min
  6. 36Format Values with sprintfStrings15 min
  7. 37Pad and Repeat StringsStrings15 min
  8. 38Escape Text for HTML OutputSecurity15 min
  9. 39Encode URL ComponentsStrings15 min

Stage 6 · Lessons 40–59

Control flow and arrays in depth

Strict comparisons, match, loop control, sorting, grouping and sets.

20 of 20 published
  1. 40Numeric Strings and Explicit ConversionTypes15 min
  2. 41Strict Comparisons and Type JugglingTypes15 min
  3. 42Return Values with match ExpressionsControl flow15 min
  4. 43Choose Branches with switchControl flow15 min
  5. 44Break and Continue in LoopsLoops15 min
  6. 45Work with Nested LoopsLoops15 min
  7. 46Navigate Multidimensional ArraysArrays15 min
  8. 47Work with Array Keys and ValuesArrays15 min
  9. 48Search Arrays with Strict MembershipArrays15 min
  10. 49Sort Array Values PredictablyArrays15 min
  11. 50Sort Associative ArraysArrays15 min
  12. 51Write Custom Array ComparatorsArrays15 min
  13. 52Slice and Splice ArraysArrays15 min
  14. 53Merge Arrays and Replace KeysArrays15 min
  15. 54Compare Arrays as SetsArrays15 min
  16. 55Remove Duplicate Array ValuesArrays15 min
  17. 56Group Records by a Shared KeyArrays15 min
  18. 57Chunk Data into BatchesArrays15 min
  19. 58Aggregate Records with array_reduceArrays15 min
  20. 59Combine Related ArraysArrays15 min

Stage 7 · Lessons 60–83

Functions, types and classes in depth

Recursion, references, union types, readonly classes and composition.

24 of 24 published
  1. 60Accept Variable ArgumentsFunctions15 min
  2. 61Unpack Function ArgumentsFunctions15 min
  3. 62Call Functions with Named ArgumentsFunctions15 min
  4. 63Understand Pass by ReferenceFunctions15 min
  5. 64Solve Small Problems with RecursionFunctions15 min
  6. 65Build Predictable Pure FunctionsFunctions15 min
  7. 66Pass Behavior into Higher-Order FunctionsFunctions15 min
  8. 67Capture Values in ClosuresFunctions15 min
  9. 68Model Alternatives with Union TypesTypes15 min
  10. 69Require Multiple Interfaces with Intersection TypesTypes15 min
  11. 70Design Nullable Function ContractsTypes15 min
  12. 71Use Strict Scalar Type CheckingTypes15 min
  13. 72Navigate Optional Objects with Nullsafe CallsClasses15 min
  14. 73Control Property VisibilityClasses15 min
  15. 74Protect Values with Readonly PropertiesClasses15 min
  16. 75Create Readonly Value ObjectsClasses15 min
  17. 76Use Static Methods and ConstantsClasses15 min
  18. 77Name Domain Values with Class ConstantsClasses15 min
  19. 78Share Contracts with Abstract ClassesClasses15 min
  20. 79Compose Objects from Smaller BehaviorsClasses15 min
  21. 80Inject Object DependenciesClasses15 min
  22. 81Build Small Value ObjectsClasses15 min
  23. 82Clone Objects DeliberatelyClasses15 min
  24. 83Give Objects a String RepresentationClasses15 min

Stage 8 · Lessons 84–100

Modern PHP in practice

Enums, error handling, JSON, iterators, generators and reflection.

16 of 17 published
  1. 84Control Object JSON SerializationJSON15 min
  2. 85Map External Values to Backed EnumsEnums15 min
  3. 86Attach Behavior to Enum CasesEnums15 min
  4. 87Define Domain-Specific ExceptionsErrors15 min
  5. 88Guarantee Cleanup with finallyErrors15 min
  6. 89Handle JSON Failures ExplicitlyJSON15 min
  7. 90Validate JSON Before DecodingJSON15 min
  8. 91Extract Values with Regex CapturesRegular expressions15 min
  9. 92Transform Text with Regex CallbacksRegular expressions15 min
  10. 93Normalize Inputs Before ValidationValidation15 min
  11. 94Build and Parse Query StringsHTTP concepts15 min
  12. 95Calculate with DateTimeImmutableDates15 min
  13. 96Add and Compare Date IntervalsDates15 min
  14. 97Yield Values with GeneratorsIteration15 min
  15. 98Implement a Simple IteratorAggregateIteration15 min
  16. 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 →