exit

Output a message and terminate the current script

Syntax

exit ([ string $status ] ) : void
exit ( int $status ) : void

Parameters

status

If status is a string, this function prints the status just before exiting.

If status is an integer, that value will be used as the exit status and not printed. Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used. The status 0 is used to terminate the program successfully.

Return

No value is returned.

Examples

1 · void

<?

exit;
exit();

echo "no output";

?>

			
		

2 · status · string

<?

exit("exit");

echo "no output";

?>
exit

3 · status · int

<?

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

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

echo "no output";

?>

			
		

4 · 1

<?

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

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

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

fclose($handle);

?>

			
		

__halt_compiler

connection_aborted

connection_status

constant

define

defined

die

eval

highlight_file

highlight_string

hrtime

ignore_user_abort

pack

php_strip_whitespace

show_source

sleep

sys_getloadavg

time_nanosleep

time_sleep_until

uniqid

unpack

usleep

PHP

Home Menu