PHP » Control Structures » die()

Syntax:
void die([mixed status])
status
Message to print or status to return.

Stops the execution of a script.

die() immediately stops the execution of the script. It is often used together with the OR operator, to quit executing when a crucial call fails. The optional status parameter can either be a string or an integer. Strings are printed and integers are returned as the exit status.

Examples

Code:
<?php

@mysql_connect("host_that_does_not_exist")
   or die("Could not connect to db. Die.");

?>
Output:
Could not connect to db. Die.
Explanation:

If something like a connection to a database cannot be made, if is often not meaningful to continue executing the script.

See Also: