PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<evalget_browser>
Last updated: Mon, 16 Jul 2012

exit

(PHP 3, PHP 4, PHP 5 )

exit -- Output a message and terminate the current script

Description

void exit ( [string status] )

void exit ( int status )

注: This is not a real function, but a language construct.

注: PHP >= 4.2.0 does NOT print the status if it is an integer.

The exit() function terminates execution of the script. It prints status just before exiting.

If status is an integer, that value will also be used as the exit status. 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.

例子 1. exit() example

<?php

$filename
= '/path/to/data-file';
$file = fopen($filename, 'r')
   or exit(
"unable to open file ($filename)");

?>

例子 2. exit() status example

<?php

//exit program normally
exit;
exit();
exit(
0);

//exit with an error code
exit(1);
exit(
0376); //octal

?>

注: The die() function is an alias for exit().

See also: register_shutdown_function().




<evalget_browser>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST