Why using "or die()" in PHP is a bad practice
Daniel wrote a nice article on phpfreaks.com describing why it's bad practice to use "or die()" in your php code.
Reasons such as:
- It's not a very nice way to present the user with an error message.
- Using for instance the mysql_error() call with it, as many people do, exposes information that should never get output in a production environment
- You cannot catch the error in any way.
- You cannot log the error.
- You cannot control whether it should be output to the screen or not. It's okay to do that in a development environment, but certainly not in a production environment.
- It prevents you from doing any sort of cleanup. It just ends the script abruptly.