I have attached patches to bugs #50311 and #50317. I also cleaned up
the strrpos() page while I was at it seeing as #50317 is about that
function.
I had been thinking about getting more involved in the PHP project
lately. Seeing as my C skills aren't too sharp I figured I'd start
with the documentation. Should I just apply for an SVN account now, or
should I keep sending in patches?
--
Daniel Egeberg
Index: en/reference/var/functions/intval.xml
===================================================================
--- en/reference/var/functions/intval.xml (revision 292149)
+++ en/reference/var/functions/intval.xml (working copy)
@@ -16,7 +16,8 @@
<para>
Returns the <type>integer</type> value of <parameter>var</parameter>,
using the specified <parameter>base</parameter> for the conversion
- (the default is base 10).
+ (the default is base 10). You cannot use <function>intval</function> on
+ objects.
</para>
</refsect1>
@@ -92,6 +93,8 @@
echo intval('420000000000000000000'); // 2147483647
echo intval(42, 8); // 42
echo intval('42', 8); // 34
+echo intval(array()); // 0
+echo intval(array('foo', 'bar')); // 1
?>
]]>
</programlisting>
Index: en/reference/var/functions/floatval.xml
===================================================================
--- en/reference/var/functions/floatval.xml (revision 292149)
+++ en/reference/var/functions/floatval.xml (working copy)
@@ -24,7 +24,7 @@
<listitem>
<para>
May be any scalar type. You cannot use <function>floatval</function>
- on arrays or objects.
+ on objects.
</para>
</listitem>
</varlistentry>
@@ -34,7 +34,8 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
- The float value of the given variable.
+ The float value of the given variable. Empty arrays return 0, non-empty
+ arrays return 1.
</para>
</refsect1>
<refsect1 role="examples">
Index: en/reference/strings/functions/strrpos.xml
===================================================================
--- en/reference/strings/functions/strrpos.xml (revision 292149)
+++ en/reference/strings/functions/strrpos.xml (working copy)
@@ -22,52 +22,6 @@
as the needle, then only the first character of that string will
be used.
</para>
- <para>
- If <parameter>needle</parameter> is not found, returns &false;.
- </para>
- <para>
- It is easy to mistake the return values for "character found at
- position 0" and "character not found". Here's how to detect
- the difference:
- <informalexample>
- <programlisting role="php">
-<![CDATA[
-<?php
-
-// in PHP 4.0.0 and newer:
-$pos = strrpos($mystring, "b");
-if ($pos === false) { // note: three equal signs
- // not found...
-}
-
-// in versions older than 4.0.0:
-$pos = strrpos($mystring, "b");
-if (is_bool($pos) && !$pos) {
- // not found...
-}
-?>
-]]>
- </programlisting>
- </informalexample>
- </para>
- <para>
- If <parameter>needle</parameter> is not a string, it is converted
- to an integer and applied as the ordinal value of a character.
- </para>
- <note>
- <simpara>
- As of PHP 5.0.0 <parameter>offset</parameter> may
- be specified to begin searching an arbitrary number of characters into
- the string. Negative values will stop searching at an arbitrary point
- prior to the end of the string.
- </simpara>
- </note>
- <note>
- <simpara>
- The <parameter>needle</parameter> may be a string of more than one
- character as of PHP 5.0.0.
- </simpara>
- </note>
</refsect1>
<refsect1 role="parameters">
@@ -78,6 +32,7 @@
<term><parameter>haystack</parameter></term>
<listitem>
<para>
+ The string to search in.
</para>
</listitem>
</varlistentry>
@@ -85,13 +40,25 @@
<term><parameter>needle</parameter></term>
<listitem>
<para>
+ If <parameter>needle</parameter> is not a string, it is converted
+ to an integer and applied as the ordinal value of a character.
</para>
+ <note>
+ <simpara>
+ The <parameter>needle</parameter> may be a string of more than one
+ character as of PHP 5.0.0.
+ </simpara>
+ </note>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>offset</parameter></term>
<listitem>
<para>
+ As of PHP 5.0.0 <parameter>offset</parameter> may
+ be specified to begin searching an arbitrary number of characters into
+ the string. Negative values will stop searching at an arbitrary point
+ prior to the end of the string.
</para>
</listitem>
</varlistentry>
@@ -102,10 +69,63 @@
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
-
+ Returns the position where the needle exists. Returns &false; if the needle
+ was not found.
</para>
</refsect1>
+
+ <refsect1 role="examples">
+ &reftitle.examples;
+ <para>
+ <example>
+ <title>Checking if a needle is in the haystack</title>
+ <para>
+ It is easy to mistake the return values for "character found at
+ position 0" and "character not found". Here's how to detect
+ the difference:
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+// in PHP 4.0.0 and newer:
+$pos = strrpos($mystring, "b");
+if ($pos === false) { // note: three equal signs
+ // not found...
+}
+
+// in versions older than 4.0.0:
+$pos = strrpos($mystring, "b");
+if (is_bool($pos) && !$pos) {
+ // not found...
+}
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
+ <example>
+ <title>Searching with offsets</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$foo = "0123456789a123456789b123456789c";
+
+var_dump(strrpos($foo, '7', -5)); // Starts looking backwards five positions
+ // from the end. Result: int(17)
+
+var_dump(strrpos($foo, '7', 20)); // Starts searching 20 positions into the
+ // string. Result: int(27)
+
+var_dump(strrpos($foo, '7', 28)); // Result: bool(false)
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ </refsect1>
+
<refsect1 role="seealso">
&reftitle.seealso;
<para>