WordPress uses PHP as the core language. So die() would be just fine to use. In fact, I have used it several times and did not notice any major bugs. Never wonder what is the real different between them before I tried the wp_die() yesterday.
This is how it is different on the look:


So, rather than design of output, what are the differences between these?
Documentation
- die() = exit() = Output a message and terminate the current script.
- wp_die() – Kills WordPress execution and displays HTML page with an error message.
When to use wp_die() and die()
This completely based on my experience so please feel free to share yours.
- die() output is ugly. Not good for user experience. If you want to display the error to front-end users in a better way, should use wp_die() instead.
- If you want to pass arguments to control behavior, use wp_die(). It has more options than die().
- Use of wp_die() will allow other plugins / functions to hook into the event sequence.
Leave a Reply