TARDIS Placeholder
 

Best Practice Approach to Using die() in PHP

If you've gotta go... go with some style! Sometimes you just need to work out which route you're taking through a piece of code and one of the oldest debugging tricks in the book is to put some die() statements in your code and wait to fall through the cracks. If you're lazy, you tend to end putting in some pretty dumb messages. I mean, who has time to come up with sensible (or witty) explanations of where your code is slamming face first into the ground like Wile E Coyote finding the bottom of a canyon?

Fear not - here's the only die() statement you will ever need. Clear, concise, and compelling.

die(__FILE__ . ': ' . __LINE__);

Just don't leave it in production.


Site Powered By:  Kirby, Bootstrap 5, Masonry