Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I've seen people exit/die at the end of certain statements, never inside the die() itself.
I know you can echo strings in them but whether the method would execute I'm not sure! If it does then I'd say it's saying the extra line so maybe not such bad practice.
Doubt I'd do that though. Never know! I'd probably do all the methods in the IF and then die after them all. -
@SweetHuman die is usually used for error handling but it's bad practice because its not recoverable and just prints a string. It's usually better to use exceptions to recover from issues :) I don't think there's any point to the die statements above cause it'll hit the else :)
Related Rants
So, I was fixing some code today, and stumbled upon this. Is it just me, or is this really an example of bad bad practice...? And, no, there was nothing to be executed after this function was called.
undefined
php
die
why?