Skip to content

Php Programming Textbook

A free, self-paced textbook in 7 chapters. Read a chapter, then drill it with the 50 companion flashcards using spaced repetition.

7 chapters · 50 cards · Updated

Chapters

  1. 1Object-Oriented Foundations

    At the heart of modern PHP is its object-oriented programming model. A class is a blueprint that defines the properties (variables) and methods (functions) its objects will have. Y...

  2. 2Inheritance, Interfaces, and Traits

    PHP supports inheritance through the extends keyword, which lets a child class reuse and extend the behavior of a parent class. The child inherits all public and protected properti...

  3. 3Namespaces and Dependency Management

    As PHP projects grow, name collisions become inevitable: two libraries may both define a class called User or Logger. Namespaces solve this by acting as virtual directories for you...

  4. 4The PHP Type System

    Since PHP 7, type declarations have become a cornerstone of robust PHP code. Type hints let you declare the expected types of function parameters and return values, enabling PHP's...

  5. 5Working with Arrays and Strings

    PHP's array is a versatile ordered map that doubles as a list, and the language provides many built-in functions for transforming and querying them. array_map() applies a callback...

  6. 6Databases, Sessions, and Error Handling

    For database access, PHP Data Objects (PDO) provides a uniform layer across multiple database engines. You connect by instantiating PDO with a Data Source Name that encodes the dri...

  7. 7Closures, Generators, and Magic Methods

    Closures are anonymous functions that you can assign to variables, pass as arguments, or return from other functions. A regular closure captures variables from its enclosing scope...

← Back to the Php Programming deck