Understand Error, Exception, and Throwable in PHP
Distinguish PHP Error and Exception objects, catch expected failures specifically, and reserve Throwable for application boundaries.
The easy way to know
Distinguish PHP Error and Exception objects, catch expected failures specifically, and reserve Throwable for application boundaries.
Use PHP HTML escaping flags deliberately to replace malformed UTF-8 and document-type-disallowed code points without hiding input problems.
Initialize a SimpleXML iterator before reading its key, or let foreach manage rewind, validity checks, and movement automatically.
Keep PHP finally blocks limited to cleanup so they do not replace a return value or suppress an exception already in flight.
Understand how PHP stores named arguments in a variadic array and choose named or positional calls based on whether keys matter.
Check the result of grapheme_strlen(), report ICU failures safely, and distinguish grapheme clusters from bytes and code points.
Distinguish valid false values from invalid input when using FILTER_VALIDATE_BOOLEAN and FILTER_NULL_ON_FAILURE in PHP.
Prevent PHP ValueError exceptions by defining how an empty data set should behave before calling min() or max().
Measure expensive statements, execution plans, and lock waits before assuming that archiving old MySQL rows will fix application latency.
Validate TCP ports as integers from 1 through 65535 before passing them to fsockopen() or stream_socket_client().