HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

exit

Description

The exit of Miscellaneous for PHP output a message and terminate the current script.

Syntax

exit(
    string|int $status = 0
): never

Parameters

status

If status is a string, this function prints the status just before exiting. The exit code returned by PHP is 0.

If status is an int, the exit code returned by PHP will be status.

NOTE: Exit codes should be in the range 0 to 254, the exit code 255 is reserved by PHP and should not be used.

Return

No value is returned.

Examples

1 · void

<?

exit;
exit();

echo "no output";

2 · status · string

<?

$status = "string";

exit($status);

echo "no output";
string

3 · status · int

<?

// decimal
exit(0);
exit(1);
exit(254);

// octal
exit(0000);
exit(0001);
exit(0570);

echo "no output";

4 · fopen

<?

$filename = "https://osbo.com";
$mode = "r";

$handle = fopen($filename, $mode);

    if($handle === false)
    {
        exit();
    }

fclose($handle);