diff --git a/install/fpm/configuration.xml b/install/fpm/configuration.xml index cb1324ad2..a2a1c816c 100644 --- a/install/fpm/configuration.xml +++ b/install/fpm/configuration.xml @@ -1,6 +1,6 @@ - + 配置 @@ -198,8 +198,8 @@ 设置 FPM 使用的事件机制。 - 可用以下选项:select、pool、epoll、kqueue (*BSD)、port (Solaris)。 - 默认值:不设置(自动检测) + 可用以下选项:epoll、kqueue (*BSD)、port (Solaris)、poll、select。 + 默认值:不设置(自动检测,优先使用 epoll 和 kqueue) @@ -882,8 +882,8 @@ 写入日志的时间(请求完成时)。可以接受 strftime(3) 格式 %d/%b/%Y:%H:%M:%S %z(默认)。strftime(3) 格式必须封装在 - %{<strftime_format>}t 标签中,例如,对于 ISO8601 格式的时间字符串,使用 - %{%Y-%m-%dT%H:%M:%S%z}t + %{<strftime_format>}T 标签中,例如,对于 ISO8601 格式的时间字符串,使用 + %{%Y-%m-%dT%H:%M:%S%z}T diff --git a/language/oop5/lazy-objects.xml b/language/oop5/lazy-objects.xml index c3299679d..acec6f32d 100644 --- a/language/oop5/lazy-objects.xml +++ b/language/oop5/lazy-objects.xml @@ -135,15 +135,14 @@ $post = $reflector->newLazyGhost(function ($post) { $post->__construct($data['id'], $data['title'], $data['content']); }); -// Without this line, the following call to ReflectionProperty::setValue() would -// trigger initialization. +// 如果没有这行,下面调用 ReflectionProperty::setValue() 时将触发初始化 $reflector->getProperty('id')->skipLazyInitialization($post); $reflector->getProperty('id')->setValue($post, 123); -// Alternatively, one can use this directly: +// 或者直接使用它: $reflector->getProperty('id')->setRawValueWithoutLazyInitialization($post, 123); -// The id property can be accessed without triggering initialization +// 无需触发初始化即可访问 id 属性 var_dump($post->id); ?> ]]> @@ -160,21 +159,11 @@ var_dump($post->id); 关于延迟对象策略 - Lazy ghosts are objects that initialize in-place and, - once initialized, are indistinguishable from an object that was never lazy. - This strategy is suitable when we control both the instantiation and - initialization of the object, making it unsuitable if either of these is - managed by another party. + 延迟幽灵,就地初始化的对象,并且一旦初始化,就跟从未延迟化的对象没有区别。当需要控制对象的实例化和初始化时,此策略是合适的,如果是其中任何一个由另一方管理,则不适合。 - Lazy proxies, once initialized, act as proxies to - a real instance: any operation on an initialized lazy proxy is forwarded - to the real instance. The creation of the real instance can be delegated - to another party, making this strategy useful in cases where lazy ghosts - are unsuitable. Although lazy proxies are nearly as transparent as lazy - ghosts, caution is needed when their identity is used, as the proxy and - its real instance have distinct identities. + 延迟代理一旦初始化,便充当真实实例的代理:对已初始化延迟代理的任何操作都将转发给真实实例。真实实例的创建可以委托给另一方,这使得此策略在延迟幽灵不适合的情况下非常有用。尽管延迟代理几乎与延迟幽灵一样透明,但在使用其身份时需要谨慎,因为代理和真实实例具有不同的身份。 @@ -182,36 +171,29 @@ var_dump($post->id); 延迟对象的生命周期 - Objects can be made lazy at instantiation time using - ReflectionClass::newLazyGhost or - ReflectionClass::newLazyProxy, or after - instantiation by using - ReflectionClass::resetAsLazyGhost or - ReflectionClass::resetAsLazyProxy. Following this, a - lazy object can become initialized through one of the following operations: + 对象可以使用 ReflectionClass::newLazyGhost 或 + ReflectionClass::newLazyProxy 在实例化时设置为延迟,或者使用 + ReflectionClass::resetAsLazyGhost 或 + ReflectionClass::resetAsLazyProxy 在实例化后设置为延迟。之后可以通过下列操作之一初始化延迟对象: - Interacting with the object in a way that triggers automatic initialization. See - Initialization - triggers. + 以触发自动初始化的方式与对象进行交互。参阅初始化触发器。 - Marking all its properties as non-lazy using - ReflectionProperty::skipLazyInitialization or - ReflectionProperty::setRawValueWithoutLazyInitialization. + 使用 ReflectionProperty::skipLazyInitialization 或 + ReflectionProperty::setRawValueWithoutLazyInitialization + 将其所有属性标注为非延迟。 - Calling explicitly ReflectionClass::initializeLazyObject - or ReflectionClass::markLazyObjectAsInitialized. + 明确调用 ReflectionClass::initializeLazyObject + 或 ReflectionClass::markLazyObjectAsInitialized - As lazy objects become initialized when all their properties are marked - non-lazy, the above methods will not mark an object as lazy if no properties - could be marked as lazy. + 由于延迟对象在所有属性均标记为非惰性时才会初始化,因此如果没有属性可以标记为延迟,则上述方法不会将对象标记为延迟。 diff --git a/language/predefined/variables/argv.xml b/language/predefined/variables/argv.xml index 919775a46..ee971bab3 100644 --- a/language/predefined/variables/argv.xml +++ b/language/predefined/variables/argv.xml @@ -1,7 +1,7 @@ - - + + $argv @@ -23,13 +23,19 @@ 这个变量仅在 register_argc_argv 打开时可用。 + + + 要测试脚本是否从命令行运行,应使用 php_sapi_name,而不是检查是否设置了 + $argv$_SERVER['argv']。 + + &reftitle.examples; - <varname>$argv</varname> 范例 + <varname>$argv</varname> 示例 - + String 字符串 @@ -888,10 +888,10 @@ $arr = [ 'foo' => ['foo1', 'foo2', 'foo3'] ]; -// Won't work, outputs: This is { fantastic} +// 无效,输出 This is { fantastic} echo "This is { $great}"; -// Works, outputs: This is fantastic +// 有效,输出 This is fantastic echo "This is {$great}"; class Square { @@ -902,32 +902,31 @@ class Square { $square = new Square(5); -// Works +// 有效 echo "This square is {$square->width}00 centimeters wide."; -// Works, quoted keys only work using the curly brace syntax +// 有效,引用 key 仅使用花括号语法时有效 echo "This works: {$arr['key']}"; -// Works +// 有效 echo "This works: {$arr[3][2]}"; echo "This works: {$arr[DATA_KEY]}"; -// When using multidimensional arrays, always use braces around arrays -// when inside of strings +// 使用多维数组时,在字符串内部时,始终使用括号括住数组 echo "This works: {$arr['foo'][2]}"; echo "This works: {$obj->values[3]->name}"; echo "This works: {$obj->$staticProp}"; -// Won't work, outputs: C:\folder\{fantastic}.txt -echo "C:\folder\{$great}.txt"; +// 无效,输出 C:\directory\{fantastic}.txt +echo "C:\directory\{$great}.txt"; -// Works, outputs: C:\folder\fantastic.txt -echo "C:\\folder\\{$great}.txt"; +// 有效,输出 C:\directory\fantastic.txt +echo "C:\\directory\\{$great}.txt"; ?> ]]> diff --git a/reference/array/functions/array-column.xml b/reference/array/functions/array-column.xml index bdb562184..678141e48 100644 --- a/reference/array/functions/array-column.xml +++ b/reference/array/functions/array-column.xml @@ -1,7 +1,7 @@ - - + + array_column @@ -99,32 +99,34 @@ 2135, 'first_name' => 'John', 'last_name' => 'Doe', - ), - array( + ], + [ 'id' => 3245, 'first_name' => 'Sally', 'last_name' => 'Smith', - ), - array( + ], + [ 'id' => 5342, 'first_name' => 'Jane', 'last_name' => 'Jones', - ), - array( + ], + [ 'id' => 5623, 'first_name' => 'Peter', 'last_name' => 'Doe', - ) -); + ] +]; $first_names = array_column($records, 'first_name'); print_r($first_names); + ?> ]]> @@ -150,9 +152,34 @@ Array 2135, + 'first_name' => 'John', + 'last_name' => 'Doe', + ], + [ + 'id' => 3245, + 'first_name' => 'Sally', + 'last_name' => 'Smith', + ], + [ + 'id' => 5342, + 'first_name' => 'Jane', + 'last_name' => 'Jones', + ], + [ + 'id' => 5623, + 'first_name' => 'Peter', + 'last_name' => 'Doe', + ] +]; + $last_names = array_column($records, 'last_name', 'id'); print_r($last_names); + ?> ]]> @@ -196,6 +223,7 @@ $users = [ ]; print_r(array_column($users, 'username')); + ?> ]]> @@ -215,7 +243,7 @@ Array - 通过 <function>__get</function> 魔术方法从对象中获取 private 属性的 "name" 列。 + 通过 <function>__isset</function> 和 <function>__get</function> 魔术方法从对象中获取 private 属性的 "name" 列。 - + @@ -82,13 +82,16 @@ ]]> @@ -118,6 +121,7 @@ array(4) { [ 'McIntosh' => 'red', @@ -128,6 +132,7 @@ $foods = [ 'Valencia' => 'orange', ], ]; + $vegetables = [ 'lettuce' => [ 'Iceberg' => 'green', @@ -144,49 +149,52 @@ $vegetables = [ ]; array_unshift($foods, $vegetables); + var_dump($foods); + +?> ]]> &example.outputs; + [0]=> array(3) { - 'lettuce' => + ["lettuce"]=> array(2) { - 'Iceberg' => + ["Iceberg"]=> string(5) "green" - 'Butterhead' => + ["Butterhead"]=> string(5) "green" } - 'carrots' => + ["carrots"]=> array(2) { - 'Deep Purple Hybrid' => + ["Deep Purple Hybrid"]=> string(6) "purple" - 'Imperator' => + ["Imperator"]=> string(6) "orange" } - 'cucumber' => + ["cucumber"]=> array(2) { - 'Kirby' => + ["Kirby"]=> string(5) "green" - 'Gherkin' => + ["Gherkin"]=> string(5) "green" } } - 'apples' => + ["apples"]=> array(2) { - 'McIntosh' => + ["McIntosh"]=> string(3) "red" - 'Granny Smith' => + ["Granny Smith"]=> string(5) "green" } - 'oranges' => + ["oranges"]=> array(2) { - 'Navel' => + ["Navel"]=> string(6) "orange" - 'Valencia' => + ["Valencia"]=> string(6) "orange" } } diff --git a/reference/curl/constants_curl_setopt.xml b/reference/curl/constants_curl_setopt.xml index 0d5a9afff..6edeea049 100644 --- a/reference/curl/constants_curl_setopt.xml +++ b/reference/curl/constants_curl_setopt.xml @@ -3541,10 +3541,8 @@ - Set SSL behavior options, which is a bitmask of the - CURLSSLOPT_* constants. - Defaults to none of the bits being set. - Available as of PHP 7.0.7. and cURL 7.25.0. + 设置 SSL 行为选项,是 CURLSSLOPT_* + 常量的位掩码。默认未设置任何位。自 PHP 7.0.7 和 cURL 7.25.0 起可用。 @@ -3555,10 +3553,8 @@ - Set to 0 to disable and 1 to enable - SSL session-ID caching. - By default all transfers are done using the cache enabled. - Available as of cURL 7.16.0. + 设置为 0 以禁用,设置为 1 以启用 SSL 会话 + ID 缓存。默认情况下,所有传输均启用缓存。自 cURL 7.16.0 起可用。 @@ -3606,10 +3602,7 @@ - Accepts a file handle resource pointing to - an alternative location to output errors to instead of - STDERR. - Available as of cURL 7.1.0. + 接受指向替代位置的文件句柄 resource,以将错误输出到 STDERR 以外的其他位置。自 cURL 7.1.0 起可用。 @@ -3631,11 +3624,9 @@ - &true; to suppress proxy CONNECT response headers from the user callback functions - CURLOPT_HEADERFUNCTION and CURLOPT_WRITEFUNCTION, - when CURLOPT_HTTPPROXYTUNNEL is used and a CONNECT request is made. - Defaults to &false;. - Available as of PHP 7.3.0 and cURL 7.54.0. + 当使用 CURLOPT_HTTPPROXYTUNNEL 并发出 CONNECT 请求时,设置为 &true; 以抑制来自用户 callback + 函数 CURLOPT_HEADERFUNCTIONCURLOPT_WRITEFUNCTION 的代理 CONNECT + 响应 header。默认为 &false;。自 PHP 7.3.0 和 cURL 7.54.0 起可用。 @@ -3659,10 +3650,7 @@ 如果设置为 1,将发送 TCP keepalive 探针。这些探针的延迟和频率可以通过 CURLOPT_TCP_KEEPIDLECURLOPT_TCP_KEEPINTVL 选项来控制,前提是操作系统支持它们。如果设置为 0(默认值),将禁用 - keepalive 探针。 - The maximum number of probes can be set with the CURLOPT_TCP_KEEPCNT - option. - Available as of cURL 7.25.0. + keepalive 探针。可以使用 CURLOPT_TCP_KEEPCNT 选项设置最大探测次数。自 cURL 7.25.0 起可用。