8

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.

Comments
  • 2
    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.
  • 3
    Or just not die() at all given that nothing else with execute!
  • 0
    Please someone explain why is this bad.(i don't know php)
  • 1
    @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 :)
  • 0
  • 0
    The string key isn't much better
Add Comment