downloads | documentation | faq | getting help | mailing lists | reporting bugs | sites | links | my 
search for in the  
Last updated: Mon, 16 Jul 2012


(PHP 3, PHP 4, PHP 5 )

exit -- Output a message and terminate the current script


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


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


例子 2. exit() status example


//exit program normally

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


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

See also: register_shutdown_function().

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