mirror of
https://github.com/php/doc-ja.git
synced 2026-03-27 00:22:08 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@351153 c90b9560-bf6c-de11-be94-00142212c4b1
184 lines
4.4 KiB
XML
184 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 86e6094e86b84a51d00ab217ac50ce8dde33d82a Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: takagi -->
|
|
<refentry xml:id="function.exit" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>exit</refname>
|
|
<refpurpose>メッセージを出力し、現在のスクリプトを終了する</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>void</type><methodname>exit</methodname>
|
|
<methodparam choice="opt"><type>string</type><parameter>status</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<methodsynopsis>
|
|
<type>void</type><methodname>exit</methodname>
|
|
<methodparam><type>int</type><parameter>status</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
スクリプトの実行を終了します。
|
|
<link linkend="function.register-shutdown-function">シャットダウン関数</link>
|
|
や <link linkend="language.oop5.decon.destructor">オブジェクトのデストラクタ</link>
|
|
は、<literal>exit</literal> がコールされた場合にも実行されます。
|
|
</para>
|
|
<para>
|
|
<literal>exit</literal> は言語構造です。
|
|
<parameter>status</parameter> を指定しない場合は括弧なしでコールできます。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>status</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<parameter>status</parameter> が文字列の場合は、この関数は終了直前に
|
|
<parameter>status</parameter> を表示します。
|
|
</para>
|
|
<para>
|
|
<parameter>status</parameter> が <type>int</type> の場合は
|
|
その値が終了ステータスとして使われ、表示はされません。終了ステータスは
|
|
0 から 254 までの値でなければなりません。終了ステータス 255 は
|
|
PHP に予約されており、使用してはいけません。ステータス 0 は、
|
|
プログラムを正常終了させる際に使用します。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.void;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><literal>exit</literal> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$filename = '/path/to/data-file';
|
|
$file = fopen($filename, 'r')
|
|
or exit("ファイル ($filename) をオープンできません");
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><literal>exit</literal> でステータスを指定する例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
// 正常終了
|
|
exit;
|
|
exit();
|
|
exit(0);
|
|
|
|
// エラーコードつきの終了
|
|
exit(1);
|
|
exit(0376); // 八進数
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>シャットダウン関数やデストラクタが実行される例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?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 'これは出力されません。';
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Shutdown: shutdown()
|
|
Destruct: Foo::__destruct()
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
|
|
¬e.language-construct;
|
|
|
|
<note>
|
|
<para>
|
|
この言語構造は、<function>die</function> と等価です。
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>register_shutdown_function</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|