svn: /phpdoc/zh/trunk/language/types/ object.xml

[email protected] (Dai Jie)
Newsgroups php.doc.zh
Message-ID <[email protected]>
daijie                                   Fri, 16 Nov 2018 15:53:26 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=345991

Log:
Fix #77098 [ZH] Wrong explanation for object inversion from array to object

Bug: https://bugs.php.net/77098 (Verified) [ZH] Wrong explanation for object inversion from array to object
      
Changed paths:
    U   phpdoc/zh/trunk/language/types/object.xml

Modified: phpdoc/zh/trunk/language/types/object.xml
===================================================================
--- phpdoc/zh/trunk/language/types/object.xml	2018-11-16 15:42:43 UTC (rev 345990)
+++ phpdoc/zh/trunk/language/types/object.xml	2018-11-16 15:53:26 UTC (rev 345991)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Revision$ -->
-<!-- EN-Revision: 335216 Maintainer: Altair Status: ready -->
+<!-- EN-Revision: 344924 Maintainer: Altair Status: ready -->
 <!-- CREDITS: Geogory, dallas -->
 <sect1 xml:id="language.types.object">
  <title>Object 对象</title>
@@ -44,7 +44,7 @@
    如果将一个对象转换成对象,它将不会有任何变化。如果其它任何类型的值被转换成对象,将会创建一个内置类
    <literal>stdClass</literal> 的实例。如果该值为
    &null;,则新的实例为空。
-   <type>array</type> 转换成 <type>object</type> 将使键名成为属性名并具有相对应的值,除了数字键,不迭代就无法被访问。
+   <type>array</type> 转换成 <type>object</type> 将使键名成为属性名并具有相对应的值。注意:在这个例子里, 使用 PHP 7.2.0 之前的版本,数字键只能通过迭代访问。
   </para>

   <informalexample>
@@ -52,8 +52,8 @@
 <![CDATA[
 <?php
 $obj = (object) array('1' => 'foo');
-var_dump(isset($obj->{'1'})); // outputs 'bool(false)'
-var_dump(key($obj)); // outputs 'int(1)'
+var_dump(isset($obj->{'1'})); // PHP 7.2.0 后输出 'bool(true)',之前版本会输出 'bool(false)'
+var_dump(key($obj)); // PHP 7.2.0 后输出 'string(1) "1"',之前版本输出  'int(1)'
 ?>
 ]]>
    </programlisting>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.