Leanpub Header

Skip to main content

Modern PHP Mastery

From Fundamentals to Expert-Level Programming with PHP 8

Modern PHP Mastery
This book is 100% completeLast updated on 2026-10-07

Master modern PHP from the ground up with this comprehensive guide to PHP 8.x. From basic syntax and variables to advanced features such as fibers, intersection types, and memory management, this book combines practical examples, real-world insights, and hands-on exercises to help you develop expert-level PHP skills and a deep understanding of the language itself.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
186
Pages
About

About

About the Book

PHP has undergone a remarkable transformation over the last decade. What was once dismissed as a simple scripting language for generating dynamic web pages has evolved into a modern, type-safe, and expressive programming language. This book takes you on a comprehensive journey from absolute beginner to expert-level proficiency in modern PHP (8.x). Every chapter builds upon the last, covering everything from basic syntax and variables to advanced topics like fibers, intersection types, and memory management. Through progressively complex examples, real-world scenarios, exercises, and best practices drawn from production experience, you will develop a deep understanding of the PHP language itself. No frameworks, no shortcuts, just pure PHP mastery.

Bundle

Bundles that include this book

Author

About the Author

Steve Publications

Steve is a technology professional with over 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. He specializes in analyzing complex systems, identifying weaknesses and improving security.

Beyond his professional work, Steve collaborates with researchers and industry experts to create practical technical books covering software development, cybersecurity, cloud computing, DevOps, AI and enterprise technologies. His goal is to help IT professionals, students and enthusiasts develop practical skills through clear explanations, real-world examples and hands-on exercises.

At Steve Publications, we use AI to assist with translation, proofreading and editing but not to replace the research, technical expertise or hands-on experience behind our books. Some authors publish under pseudonyms for privacy or professional reasons.

Every book is written, reviewed and maintained by experienced professionals, supported by a private community of over 420 engineers and researchers. We prioritize technical accuracy, practical value and regularly updated content over mass-produced AI-generated text.

We welcome experienced professionals interested in writing or reviewing books, especially in specialized and emerging technology fields. If you'd like to contribute, contact us with your area of expertise.

We stand behind our work. If a book doesn't meet your expectations, Leanpub offers a 60-day money-back guarantee.

Contents

Table of Contents

From Fundamentals to Expert-Level Programming with PHP 8

Introduction: The PHP You Don’t Know Yet

  1. Why This Book?
  2. How This Book Is Structured
  3. What You Need to Get Started
  4. How to Read This Book
  5. A Note on PHP Versions

Chapter 1: Getting Started with PHP

  1. What Is PHP?
  2. Installing and Configuring PHP
  3. Your First PHP Program
  4. How PHP Executes Code
  5. Development Tools and IDEs
  6. Chapter Summary
  7. Review Questions
  8. Hands-On Exercise

Chapter 2: Variables, Data Types and Constants

  1. Variables and Naming Conventions
  2. Scalar Types
  3. Compound Types
  4. Special Types
  5. Constants and Typed Constants
  6. Type Juggling and Strict Types
  7. Deep Dive: How PHP Stores Values Internally
  8. Chapter Summary
  9. Review Questions
  10. Hands-On Exercise

Chapter 3: Operators and Expressions

  1. Arithmetic and Assignment Operators
  2. Comparison Operators
  3. Logical and Bitwise Operators
  4. Null Coalescing and Elvis Operators
  5. String Concatenation and Interpolation
  6. Operator Precedence and Associativity
  7. Chapter Summary
  8. Review Questions
  9. Hands-On Exercise

Chapter 4: Control Flow

  1. If, Elseif and Else Statements
  2. Switch Statements
  3. The Match Expression (PHP 8.0+)
  4. For, Foreach, While and Do-While Loops
  5. Break, Continue and Goto
  6. Error Control Operator (@)
  7. Chapter Summary
  8. Review Questions
  9. Hands-On Exercise

Chapter 5: Functions Deep Dive

  1. Defining and Calling Functions
  2. Parameters, Arguments and Default Values
  3. Named Arguments (PHP 8.0+)
  4. Variable-Length Arguments (…args)
  5. Return Types and Union Types
  6. Anonymous Functions and Closures
  7. Arrow Functions (PHP 7.4+)
  8. First-Class Callable Syntax (PHP 8.1+)
  9. Recursion and Callbacks
  10. Chapter Summary
  11. Review Questions
  12. Hands-On Exercise

Chapter 6: Arrays – PHP’s Workhorse

  1. Indexed and Associative Arrays
  2. Multidimensional Arrays
  3. Array Functions (Map, Filter, Reduce Patterns)
  4. Array Destructuring (PHP 7.1+)
  5. SplFixedArray and Specialized Arrays
  6. Performance Considerations with Large Arrays
  7. Chapter Summary
  8. Review Questions
  9. Hands-On Exercise

Chapter 7: Strings and Text Processing

  1. String Literals (Single vs Double Quotes)
  2. String Functions and Manipulation
  3. String Interpolation and Heredoc/Nowdoc
  4. Regular Expressions with PCRE
  5. Multibyte String Handling (mbstring)
  6. String Comparison and Collation
  7. Chapter Summary
  8. Review Questions
  9. Hands-On Exercise

Chapter 8: Object-Oriented Programming Foundations

  1. Classes and Objects
  2. Properties and Visibility
  3. Methods and the $this Keyword
  4. Constructors and Destructors
  5. Static Properties and Methods
  6. Magic Methods
  7. Late Static Binding
  8. Chapter Summary
  9. Review Questions
  10. Hands-On Exercise

Chapter 9: Advanced Object-Oriented Features

  1. Inheritance and Method Overriding
  2. Abstract Classes and Methods
  3. Interfaces and Multiple Interface Implementation
  4. Traits and Trait Conflicts
  5. Readonly Properties and Classes (PHP 8.1+)
  6. Enums (PHP 8.1+)
  7. Chapter Summary
  8. Review Questions
  9. Hands-On Exercise

Chapter 10: Namespaces, Autoloading and Attributes

  1. Namespaces and Aliasing
  2. PSR-4 Autoloading Standard
  3. Composer and Dependency Management
  4. Attributes (PHP 8.0+)
  5. Reflection API
  6. The Standard PHP Library (SPL)
  7. Chapter Summary
  8. Review Questions
  9. Hands-On Exercise

Chapter 11: Error Handling and Exceptions

  1. Errors vs Exceptions in PHP
  2. Try, Catch, Finally Blocks
  3. Custom Exception Classes
  4. The Throwable Interface Hierarchy
  5. Error Handling Functions and Callbacks
  6. The Nullsafe Operator (PHP 8.0+)
  7. Debugging Techniques
  8. Chapter Summary
  9. Review Questions
  10. Hands-On Exercise

Chapter 12: Generators, Iterators and Fibers

  1. Generators (yield)
  2. Generator Delegation (yield from)
  3. Generator Send and Return Values
  4. Iterator Interface and SPL Iterators
  5. The Iterable Pseudo-Type
  6. Fibers (PHP 8.1+)
  7. Chapter Summary
  8. Review Questions
  9. Hands-On Exercise

Chapter 13: File I/O, Streams and Serialization

  1. File Reading and Writing
  2. Directory Operations
  3. Stream Wrappers and Filters
  4. JSON Encoding and Decoding
  5. Serialization and Unserialization
  6. CSV Processing
  7. Chapter Summary
  8. Review Questions
  9. Hands-On Exercise

Chapter 14: Type System Mastery

  1. Scalar Type Declarations
  2. Return Type Declarations
  3. Union Types (PHP 8.0+)
  4. Intersection Types (PHP 8.1+)
  5. The Standalone Null and False Types (PHP 8.2+)
  6. The True Type (PHP 8.2+)
  7. Typed Class Constants (PHP 8.3+)
  8. Type System Deep Dive: How PHP Checks Types
  9. Chapter Summary
  10. Review Questions
  11. Hands-On Exercise

Chapter 15: Performance, Security and Professional Practices

  1. Memory Management and Garbage Collection
  2. Performance Optimization Techniques
  3. Security Best Practices at the Language Level
  4. Coding Standards (PSR-12)
  5. Static Analysis with PHPStan and Psalm
  6. Testing Fundamentals (PHPUnit basics)
  7. Modern Development Workflow
  8. Chapter Summary
  9. Review Questions
  10. Hands-On Exercise

Conclusion: The Future of PHP

  1. Where to Go From Here
  2. The Bigger Picture
  3. Final Thoughts

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub