Re: [RFC] Comparison and conversion inconsistency - need more info
| From: | Yasuo Ohgaki | Date: | Thu, 14 Nov 2013 23:03:46 +0000 |
| Subject: | Re: [RFC] Comparison and conversion inconsistency - need more info | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70144@lists.php.net to get a copy of this message | ||
Hi all,
On Tue, Nov 12, 2013 at 4:03 AM, Sanford Whiteman <
swhitemanlistens-software@cypressintegrated.com> wrote:
> > You don't have to think the current documentation is awful to find ways
> > of improving it.
>
> Sure, go for it!
I wrote my misunderstanding to my personal blog. It seems many people
misunderstand it, just like me :)
Any improvement/correction?
min() manual page is better to be updated. I'll add min() example blow to
min() manual
page also.
Index: operators.xml
===================================================================
--- operators.xml (リビジョン 332115)
+++ operators.xml (作業コピー)
@@ -1262,7 +1262,7 @@
<row>
<entry><type>bool</type> or <type>null</type></entry>
<entry>anything</entry>
- <entry>Convert to <type>bool</type>, &false; <
&true;</entry>
+ <entry>Convert to <type>bool</type> both side, &false; <
&true;</entry>
</row>
<row>
<entry><type>object</type></entry>
@@ -1298,8 +1298,28 @@
</tbody>
</tgroup>
</table>
+
<para>
<example>
+ <title>Boolean/null comparison</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+// Bool and null are compared as bool always
+var_dump(1 == TRUE); // TRUE - same as (bool)1 == TRUE
+var_dump(0 == FALSE); // TRUE - same as (bool)0 == FALSE
+var_dump(100 < TRUE); // FALSE - same as (bool)100 < TRUE
+var_dump(-10 < FALSE);// FALSE - same as (bool)-10 < FALSE
+var_dunp(min(-100,-10, NULL, 10, 100); // NULL - (bool)NULL < (bool)-100
is FALSE < TRUE
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+
+
+ <para>
+ <example>
<title>Transcription of standard array comparison</title>
<programlisting role="php">
<![CDATA[