svn: /phpdoc/en/trunk/reference/strings/functions/ substr.xml
| From: | Justin Martin | Date: | Sun, 07 Nov 2010 15:27:33 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/strings/functions/ substr.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-7386@lists.php.net to get a copy of this message | ||
frozenfire Sun, 07 Nov 2010 15:27:33 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=305162
Log:
Indicated that substr does not accept an empty string.
Added an example of casting behaviour.
Changed paths:
U phpdoc/en/trunk/reference/strings/functions/substr.xml
Modified: phpdoc/en/trunk/reference/strings/functions/substr.xml
===================================================================
--- phpdoc/en/trunk/reference/strings/functions/substr.xml 2010-11-07 15:15:36 UTC (rev 305161)
+++ phpdoc/en/trunk/reference/strings/functions/substr.xml 2010-11-07 15:27:33 UTC (rev 305162)
@@ -28,7 +28,7 @@
<term><parameter>string</parameter></term>
<listitem>
<para>
- The input string.
+ The input string. Must be one character or longer.
</para>
</listitem>
</varlistentry>
@@ -117,7 +117,7 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
- Returns the extracted part of string&return.falseforfailure;.
+ Returns the extracted part of string, &return.falseforfailure; or an empty string.
</para>
</refsect1>
@@ -145,7 +145,41 @@
?>
]]>
</programlisting>
- </example>
+ </example>
+ <example>
+ <title><function>substr</function> casting behaviour</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+class apple {
+ public function __toString() {
+ return "green";
+ }
+}
+
+echo "1) ".var_export(substr("pear", 0, 2), true).PHP_EOL;
+echo "2) ".var_export(substr(54321, 0, 2), true).PHP_EOL;
+echo "3) ".var_export(substr(new apple(), 0, 2), true).PHP_EOL;
+echo "4) ".var_export(substr(true, 0, 1), true).PHP_EOL;
+echo "5) ".var_export(substr(false, 0, 1), true).PHP_EOL;
+echo "6) ".var_export(substr("", 0, 1), true).PHP_EOL;
+echo "7) ".var_export(substr(1.2e3, 0, 4), true).PHP_EOL;
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+1) 'pe'
+2) '54'
+3) 'gr'
+4) '1'
+5) false
+6) false
+7) '1200'
+]]>
+ </screen>
+ </example>
</para>
</refsect1>