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

 ID:               52372
 Updated by:       [email protected]
 Reported by:      imagine7xy at gmail dot com
 Summary:          Comparison variable type logic
-Status:           Open
+Status:           Bogus
 Type:             Bug
 Package:          Scripting Engine problem
 Operating System: Windows 7
 PHP Version:      5.3.2

 New Comment:

Yup.



if($string) evaluates to true if the string is not empty.  If you want a
strict 

typed comparison to true, use if($string===true)


Previous Comments:
------------------------------------------------------------------------
[2010-07-19 00:52:57] imagine7xy at gmail dot com

Description:
------------
Pretty self explanatory code, is this how PHP is supposed to behave?

Test script:
---------------
<?php

// outputs string instead of else?

$foo = true;

if ($foo == false) {

        echo "not";

} elseif ($foo == "string") {

        echo "string";

} else {

        echo "else";

}

?>

Expected result:
----------------
output of "else"

Actual result:
--------------
output of "string"


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



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

Reply via email to