(unknown)
die --
Output a message and terminate the current script
Description
void die
(string message)
die() outputs message
and terminates parsing of the script. It does not return
anything.
Alternatively, die() will also accept a
function as a parameter. That function will be executed
before die() terminates parsing of the script.
Example 1. die() example
<?php
$filename = '/path/to/data-file';
$file = fopen ($filename, 'r')
or die("unable to open file ($filename)");
?>
|
|
Example 2. die() example using a function
<?php
function handle_error($msg) {
if ($fp = @fopen("/tmp/error.log", "a")) {
fwrite($fp, $msg, strlen($msg));
fclose($fp);
}
}
if ($bad) {
die(handle_error("Something bad happened.\n"));
}
?>
|
|
See also exit().
HIVE: All information for read only. Please respect copyright! |
|