svn: /phpdoc/zh/trunk/language/ functions.xml
| From: | CHU Zhaowei | Date: | Fri, 26 May 2017 16:14:57 +0000 |
| Subject: | svn: /phpdoc/zh/trunk/language/ functions.xml | ||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-4962@lists.php.net to get a copy of this message | ||
jhdxr Fri, 26 May 2017 16:14:57 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=342514
Log:
update translation for language/functions
Changed paths:
U phpdoc/zh/trunk/language/functions.xml
Modified: phpdoc/zh/trunk/language/functions.xml
===================================================================
--- phpdoc/zh/trunk/language/functions.xml 2017-05-26 15:35:09 UTC (rev 342513)
+++ phpdoc/zh/trunk/language/functions.xml 2017-05-26 16:14:57 UTC (rev 342514)
@@ -577,51 +577,38 @@
</sect3>
<sect3 xml:id="functions.arguments.type-declaration.strict">
- <title>Strict typing</title>
+ <title>严格类型</title>
<para>
- By default, PHP will coerce values of the wrong type into the expected
- scalar type if possible. For example, a function that is given an
- <type>integer</type> for a parameter that expects a
<type>string</type>
- will get a variable of type <type>string</type>.
+
默认情况下,如果能做到的话,PHP将会强迫错误类型的值转为函数期望的标量类型。
+
例如,一个函数的一个参数期望是<type>string</type>,但传入的是<type>integer</type>,最终函数得到的将会是一个<type>string</type>类型的值。
</para>
<para>
- It is possible to enable strict mode on a per-file basis. In strict
- mode, only a variable of exact type of the type declaration will be
- accepted, or a <classname>TypeError</classname> will be thrown. The
- only exception to this rule is that an <type>integer</type> may be given
- to a function expecting a <type>float</type>.
+
可以基于每一个文件开启严格模式。在严格模式中,只有一个与类型声明完全相符的变量才会被接受,否则将会抛出一个<classname>TypeError</classname>。
+
唯一的一个例外是可以将<type>integer</type>传给一个期望<type>float</type>的函数。
</para>
<para>
- To enable strict mode, the &declare; statement is used with the
- <literal>strict_types</literal> declaration:
+ 使用 &declare; 语句和<literal>strict_types</literal>
声明来启用严格模式:
</para>
<caution>
<para>
- Enabling strict mode will also affect
- <link linkend="functions.returning-values.type-declaration">return type
declarations</link>.
+ 启用严格模式同时也会影响<link
linkend="functions.returning-values.type-declaration">返回值类型声明</link>.
</para>
</caution>
<note>
<para>
- Strict typing applies to function calls made from
- <emphasis>within</emphasis> the file with strict typing enabled, not to
- the functions declared within that file. If a file without strict
- typing enabled makes a call to a function that was defined in a file
- with strict typing, the caller's preference (weak typing) will be
- respected, and the value will be coerced.
+
严格类型适用于在<emphasis>启用严格模式的文件内</emphasis>的函数调用,而不是在那个文件内声明的函数。
+
一个没有启用严格模式的文件内调用了一个在启用严格模式的文件中定义的函数,那么将会遵循调用者的偏好(弱类型),而这个值将会被转换。
</para>
</note>
<note>
<para>
- Strict typing is only defined for scalar type declarations, and as
- such, requires PHP 7.0.0 or later, as scalar type declarations were
- added in that version.
+ 严格类型仅用于标量类型声明,也正是因为如此,这需要PHP 7.0.0
或更新版本,因为标量类型声明也是在那个版本中添加的。
</para>
</note>