(PHP 4, PHP 5, PHP 7)
exit — ���һ����Ϣ�����˳���ǰ�ű�
$status
] ) : void$status
) : void��ֹ�ű���ִ�С� ���ܵ����� exit()�� Shutdown���� �Լ� object destructors ���ǻᱻִ�С�
exit �Ǹ���ṹ�����û�� status
����Ҫ���룬����ʡ��Բ���š�
status
��� status
��һ���ַ��������˳�֮ǰ�ú������ӡ
status
��
��� status
��һ�� integer����ֵ����Ϊ�˳�״̬�룬���Ҳ��ᱻ��ӡ�����
�˳�״̬��Ӧ���ڷ�Χ0��254����Ӧʹ�ñ�PHP�������˳�״̬��255��
״̬��0���ڳɹ���ֹ����
û�з���ֵ��
Example #1 exit() ����
<?php
$filename = '/path/to/data-file';
$file = fopen($filename, 'r')
or exit("unable to open file ($filename)");
?>
Example #2 exit() ״̬������
<?php
//exit program normally
exit;
exit();
exit(0);
//exit with an error code
exit(1);
exit(0376); //octal
?>
Example #3 ������Σ�Shutdown�����������������ᱻִ��
<?php
class Foo
{
public function __destruct()
{
echo 'Destruct: ' . __METHOD__ . '()' . PHP_EOL;
}
}
function shutdown()
{
echo 'Shutdown: ' . __FUNCTION__ . '()' . PHP_EOL;
}
$foo = new Foo();
register_shutdown_function('shutdown');
exit();
echo 'This will not be output.';
?>
�������̻������
Shutdown: shutdown() Destruct: Foo::__destruct()