简体   繁体   中英

same code, different servers, different output

The code in question :

<?php /*tests added by jason*/
    echo "<br />";
    echo "count = " . $this->countModules('showcase'); 
    echo "<br />";
    echo "hidebyview = " . $hideByView;
    echo "<br />";
    if($hidebyview == true) {
        echo "T";
    }
    else {
        echo "F";
    }
    echo "<br />";
    if ($this->countModules('showcase') && $hideByView == false) {
        echo "pass";
    }
    else {
        echo "fail";
    }
    echo "<br />";
?>

Site 1 output Apache/2.2.22 (Ubuntu) PHP Version 5.3.10-1ubuntu3.7 (where everything works fine):

count = 1
hidebyview = 
F
pass

Site 2 output Apache/2.2.13 (Win32) PHP/5.3.26 (where the thing is broken) :

count = 1
hidebyview = 1
F
fail

I guess it boils down to how can the part that evaluates to "fail" evaluate to different answers?

$hideByView == false is not (always) equal to !($hidebyview == true) because of casting and other possible automatic conversions. So your debug info is not really showing you what your expression $hideByView == false evaluates to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM