philip          Tue May  2 18:05:55 2006 UTC

  Modified files:              
    /phpdoc/en/language types.xml 
  Log:
  Expand $str[42] syntax info a little more, $str{42} deprecated as of PHP 6, 
  and adjust example accordingly
  
  
http://cvs.php.net/viewcvs.cgi/phpdoc/en/language/types.xml?r1=1.164&r2=1.165&diff_format=u
Index: phpdoc/en/language/types.xml
diff -u phpdoc/en/language/types.xml:1.164 phpdoc/en/language/types.xml:1.165
--- phpdoc/en/language/types.xml:1.164  Thu Mar 30 03:45:47 2006
+++ phpdoc/en/language/types.xml        Tue May  2 18:05:54 2006
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.164 $ -->
+<!-- $Revision: 1.165 $ -->
  <chapter id="language.types">
   <title>Types</title>
 
@@ -1084,13 +1084,14 @@
      <para>
       Characters within strings may be accessed and modified by specifying the
       zero-based offset of the desired character after the string 
-      in curly braces.
+      using square array-brackets like <varname>$str[42]</varname> so think of 
+      a string as an <type>array</type> of characters.
      </para>
      <note>
       <simpara>
-       For backwards compatibility, you can still use array-brackets
-       for the same purpose. However, this syntax is deprecated as
-       of PHP 4.
+       For backwards compatibility, you may still use braces like 
+       <varname>$str{42}</varname> for the same purpose. However, this syntax 
+       is deprecated as of PHP 6.
       </simpara>
      </note>
      <para>
@@ -1101,19 +1102,22 @@
 <?php
 // Get the first character of a string
 $str = 'This is a test.';
-$first = $str{0};
+$first = $str[0];
 
 // Get the third character of a string
-$third = $str{2};
+$third = $str[2];
 
 // Get the last character of a string.
 $str = 'This is still a test.';
-$last = $str{strlen($str)-1}; 
+$last = $str[strlen($str)-1]; 
 
 // Modify the last character of a string
 $str = 'Look at the sea';
-$str{strlen($str)-1} = 'e';
-          
+$str[strlen($str)-1] = 'e';
+
+// Deprecated syntax with braces
+$third = $str{2};
+
 ?>
 ]]>
        </programlisting>

Reply via email to