Stage 1 · Lesson 4 of 10
Errors and exceptions
Modern PHP reports most failures as throwables, things you can and catch. An Exception is for problems your code can expect and handle. An Error is for failures inside PHP itself, such as calling a method on null, or a TypeError from .
Catch specific exception types with try and catch, and use finally for cleanup. Define your own, such as OrderNotFoundException, which 's exception handler can later turn into a in one place. In development, show every error. In production, log errors but never display them to users.
Common trapthe @ operator, which hides errors on a line along with their real cause, and an empty catch (\Throwable $e) {} that quietly swallows everything.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- VideoFreePHP For Beginners
Laracasts · Beginner
Free video series that builds a small app in plain PHP before any framework
- GuideFreePHP: The Right Way
Josh Lockhart and contributors · Intermediate
Modern PHP practice in one place: Composer, PSR standards, PDO and security basics
Practise
Keep handy
Also worth your time
The DNS, TCP, TLS and HTTP steps behind every request your backend will handle