ID:               44236
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jvm at jvmyers dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Strings related
 Operating System: Mac OSX 10.4.11
 PHP Version:      5.2.5
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:
------------------------------------------------------------------------

[2008-02-24 18:25:31] jvm at jvmyers dot com

Description:
------------
Note: I am on a Mac and PHP 5.2.4 is the most recent version available
from entropy.

Problem: Compound booleans expressed as string args in an 'if'
statement don't 'appear' to work as expected:

Context:
  1.  I generate an array of counters.
  2.  I dynamically generate a compound boolean based on selected
counters in the array.  (Note: since the real array is sparse, I must
use the 'empty' operator).
  3.  When I submit the compound boolean as the expression of an 'if'
statement, the 'if' appears to resolve ONLY the first element of the
compound boolean.

Conclusion: appears to be a short-circuiting issue

Case 1: 'if' expression passed as string => "1. Conditions met"
Case 2: same as Case 1, but using catenation operator => "2. Conditions
met"
Case 3: same 'if' expression but passed in context => "3. Conditions
not met"

Reproduce code:
---------------
<?php
$aArray = array(1,0);
$sCondition = "!empty($aArray[0]) && !empty($aArray[1])";
if ($sCondition)
{
        echo "Case 1. Conditions met<br />";
}
else
{
        echo "Case 1. Conditions not met<br />";
}
if ("".$sCondition."")
{
        echo "Case 2. Conditions met<br />";
}
else
{
        echo "Case 2. Conditions not met<br />";
}
if (!empty($aArray[0]) && !empty($aArray[1]))
{
        echo "Case 3. Conditions met<br />";
}
else
{
        echo "Case 3. Conditions not met<br />";
}
?>

Expected result:
----------------
See, Case 3, above.

Actual result:
--------------
See, Case 1 and Case 2, above.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44236&edit=1

Reply via email to