Created
March 31, 2012 09:13
-
-
Save yohgaki/2261192 to your computer and use it in GitHub Desktop.
Array doc improvement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: array.xml | |
=================================================================== | |
--- array.xml (リビジョン 324628) | |
+++ array.xml (作業コピー) | |
@@ -118,6 +118,61 @@ | |
</listitem> | |
</itemizedlist> | |
</para> | |
+ | |
+ <para> | |
+ From PHP 5.4, string offset access made consistent. As a result, some return values may be | |
+ different from older version. As of PHP 5.4, string offset should be integer or integer like | |
+ string, otherwise it will be in a warning. | |
+ </para> | |
+ | |
+ <example> | |
+ <title>String offset access example</title> | |
+ <programlisting role="php"> | |
+<![CDATA[ | |
+<?php | |
+$str = 'abc'; | |
+ | |
+var_dump($str['1']); // 5.4.0>=: "b", Older versions: "b" | |
+var_dump(isset($str['1'])); // 5.4.0>=: true, Older versions: ture | |
+ | |
+var_dump($str['1.0']); // 5.4.0>=: "b" with E_WARNING, Older versions: "b" | |
+var_dump(isset($str['1.0'])); // 5.4.0>=: false, Older versions: true | |
+ | |
+var_dump($str['x']); // 5.4.0>=: "a" with E_WARNING, Older versions: "a" | |
+var_dump(isset($str['x'])); // 5.4.0>=: false, Older versions: true | |
+ | |
+var_dump($str['1x']); // 5.4.0>=: "b", Older versions: "b" | |
+var_dump(isset($str['1x'])); // 5.4.0>=: true, Older versions: ture | |
+?> | |
+]]> | |
+ </programlisting> | |
+ &example.outputs; | |
+ <screen> | |
+<![CDATA[ | |
+[php-5.3]$ php-5.3 test.php | |
+string(1) "b" | |
+bool(true) | |
+string(1) "b" | |
+bool(true) | |
+string(1) "a" | |
+bool(true) | |
+string(1) "b" | |
+bool(true) | |
+[php-5.4]$ php-5.4 test.php | |
+string(1) "b" | |
+bool(true) | |
+ | |
+Warning: Illegal string offset '1.0' in /tmp/t.php on line 7 | |
+string(1) "b" | |
+bool(false) | |
+ | |
+Warning: Illegal string offset 'x' in /tmp/t.php on line 9 | |
+string(1) "a" | |
+bool(false) | |
+string(1) "b" | |
+bool(false) | |
+ </screen> | |
+ </example> | |
<para> | |
If multiple elements in the array declaration use the same key, only the last one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment