colder          Mon Apr 30 17:02:29 2007 UTC

  Modified files:              
    /phpdoc/en/language operators.xml 
  Log:
  Fix #41228 (Mention short-circuit property of some logical operators)
  
http://cvs.php.net/viewvc.cgi/phpdoc/en/language/operators.xml?r1=1.112&r2=1.113&diff_format=u
Index: phpdoc/en/language/operators.xml
diff -u phpdoc/en/language/operators.xml:1.112 
phpdoc/en/language/operators.xml:1.113
--- phpdoc/en/language/operators.xml:1.112      Fri Mar 23 14:09:51 2007
+++ phpdoc/en/language/operators.xml    Mon Apr 30 17:02:28 2007
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.112 $ -->
+<!-- $Revision: 1.113 $ -->
  <chapter id="language.operators">
   <title>Operators</title>
   <simpara>
@@ -997,6 +997,39 @@
     <link linkend="language.operators.precedence">Operator
     Precedence</link>.)
    </simpara>
+   <example>
+    <title>Logical operators illustrated</title>
+    <programlisting role="php">
+<![CDATA[
+<?php
+
+// foo() will never get called as those operators are short-circuit
+$a = (false && foo());
+$b = (true  || foo());
+$c = (false and foo());
+$d = (true  or  foo());
+
+// "||" has a greater precedence than "or"
+$e = false || true; // $e will be assigned to (false || true) which is true
+$f = false or true; // $f will be assigned to false
+var_dump($e, $f);
+
+// "&&" has a greater precedence than "and"
+$g = true && false; // $g will be assigned to (true && false) which is false
+$h = true and false; // $h will be assigned to true
+var_dump($g, $h);
+]]>
+    </programlisting>
+    &example.outputs.similar;
+    <screen>
+<![CDATA[
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+]]>
+    </screen>
+   </example>
   </sect1>
 
   <sect1 id="language.operators.string">

Reply via email to