PHP die function

The die function is used to do two things:
* Print an error message
* Halt the script

When die is encountered, no more processing will take place, and the error message passed to the function (if any) will be displayed. An example is as follows:

if (not_logged_in($user)) {
   die ("Error : $user not logged in.");

die is generally used to catch system errors such as the inability to connect to a database.

Enjoyed this post? Share it!


Leave a comment

Your email address will not be published.