11<?xml version =" 1.0" encoding =" utf-8" ?>
22<!-- $Revision$ -->
3- <!-- EN-Revision: e587d0655e426f97b3fcb431453da5030e743b23 Maintainer: HonestQiao Status: ready -->
3+ <!-- EN-Revision: 094816bd170e26abf0e057dae1cfb498dd6aad88 Maintainer: HonestQiao Status: ready -->
44<!-- CREDITS: Geogory, dallas, jwj, mowangjuanzi, Luffy -->
55<sect1 xml : id =" language.types.array" >
66 <title >Array 数组</title >
@@ -701,6 +701,11 @@ echo $b, PHP_EOL; // 打印 1
701701 级别的错误消息(PHP 8.0.0 之前是 <constant >E_NOTICE</constant > 级别),结果将是 &null; 。
702702 </para >
703703 </note >
704+ <note >
705+ <para >
706+ 解构标量值会分配 &null; 到所有变量。
707+ </para >
708+ </note >
704709 </sect3 >
705710
706711 </sect2 ><!-- end syntax -->
@@ -861,12 +866,12 @@ $arr = array('fruit' => 'apple', 'veggie' => 'carrot');
861866echo $arr['fruit'], PHP_EOL; // apple
862867echo $arr['veggie'], PHP_EOL; // carrot
863868
864- // Incorrect. This works but also throws a PHP Error because
869+ // Incorrect. This does not work and throws a PHP Error because
865870// of an undefined constant named fruit
866871//
867872// Error: Undefined constant "fruit"
868873try {
869- echo $arr[fruit]; // apple
874+ echo $arr[fruit];
870875} catch (Error $e) {
871876 echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
872877}
@@ -880,7 +885,7 @@ echo $arr['fruit'], PHP_EOL; // apple
880885echo $arr[fruit], PHP_EOL; // carrot
881886
882887// The following is okay, as it's inside a string. Constants are not looked for
883- // within strings, so no E_NOTICE occurs here
888+ // within strings, so no error occurs here
884889echo "Hello $arr[fruit]", PHP_EOL; // Hello apple
885890
886891// With one exception: braces surrounding arrays within strings allows constants
@@ -908,14 +913,6 @@ print "Hello $_GET['foo']";
908913 </programlisting >
909914 </informalexample >
910915
911- <para >
912- 当打开 <link linkend =" ini.error-reporting" >error_reporting</link > 来显示
913- <constant >E_NOTICE</constant > 级别的错误(将其设为
914- <constant >E_ALL</constant >)时将看到这些错误。默认情况下
915- <link linkend =" ini.error-reporting" >error_reporting</link >
916- 被关闭不显示这些。
917- </para >
918-
919916 <para >
920917 和在 <link linkend =" language.types.array.syntax" >语法</link >
921918 一节中规定的一样,在方括号(<literal >[</literal >” 和
@@ -1106,7 +1103,7 @@ array(3) {
11061103 <para >
11071104 在 array 定义时,用 <code >...</code > 前缀的一个 array 可以被展开到当前位置。
11081105 只有实现了 <interfacename >Traversable</interfacename > 的数组和对象才能被展开。
1109- PHP 7.4.0 开始可以使用 <code >...</code > 解包 array。
1106+ PHP 7.4.0 开始可以使用 <code >...</code > 解包 array。这也被称之为展开运算符。
11101107 </para >
11111108
11121109 <para >
0 commit comments