Skip to content

Commit 90f682d

Browse files
committed
Undefined constant throws an error instead of E_NOTICE
php/doc-en@094816b
1 parent 707cc65 commit 90f682d

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

language/types/array.xml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: eaec4ab10a65c4515ee2fb899d06e89bae3754b0 Maintainer: takagi Status: ready -->
3+
<!-- EN-Revision: 094816bd170e26abf0e057dae1cfb498dd6aad88 Maintainer: takagi Status: ready -->
44
<!-- CREDITS: hirokawa,shimooka,mumumu -->
55
<sect1 xml:id="language.types.array">
66
<title>配列</title>
@@ -941,12 +941,12 @@ $arr = array('fruit' => 'apple', 'veggie' => 'carrot');
941941
echo $arr['fruit'], PHP_EOL; // apple
942942
echo $arr['veggie'], PHP_EOL; // carrot
943943
944-
// 間違い。これは動作しますが、未定義の定数fruitを使用しているため
945-
// 同時に PHP がエラーを発生させます。
944+
// 間違い。未定義の定数fruitを使用しているため動作せず
945+
// PHP がエラーを発生させます。
946946
//
947947
// Error: Undefined constant "fruit"
948948
try {
949-
echo $arr[fruit]; // apple
949+
echo $arr[fruit];
950950
} catch (Error $e) {
951951
echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
952952
}
@@ -960,7 +960,7 @@ echo $arr['fruit'], PHP_EOL; // apple
960960
echo $arr[fruit], PHP_EOL; // carrot
961961
962962
// 以下は文字列の中であるためOKです。定数は、文字列の中では解釈されな
963-
// いため、E_NOTICEエラーはここでは発生しません
963+
// いため、エラーはここでは発生しません
964964
echo "Hello $arr[fruit]", PHP_EOL; // Hello apple
965965
966966
// 例外が1つあり、文字列の中で波括弧で配列を括った場合には、
@@ -989,21 +989,12 @@ print "Hello $_GET['foo']";
989989
</programlisting>
990990
</informalexample>
991991

992-
<para>
993-
<function>error_reporting</function> で
994-
(<constant>E_ALL</constant> を指定する等により)
995-
<literal>E_NOTICE</literal> レベルのエラー出力を有効にした場合、
996-
上記のエラーが出力されます。
997-
デフォルトでは、<link linkend="ini.error-reporting">
998-
error_reporting</link> はこれらを表示しない設定になっています。
999-
</para>
1000-
1001992
<para>
1002993
<link linkend="language.types.array.syntax"
1003-
>構文</link>の節に記述したように、角括弧
994+
>構文</link> で説明した通り、角括弧
1004995
('<literal>[</literal>' および '<literal>]</literal>')
1005-
の間には、式がなければなりません。これは
1006-
次のように書くことが可能であることを意味します
996+
の間には、式がなければなりません。つまり
997+
次のように書けるということです
1007998
</para>
1008999

10091000
<informalexample>

0 commit comments

Comments
 (0)