Can anyone explain this impossible bit of PHP logic?

Posted by user268208 on Stack Overflow See other posts from Stack Overflow or by user268208
Published on 2010-04-30T23:44:19Z Indexed on 2010/04/30 23:47 UTC
Read the original article Hit count: 154

Filed under:
|
|

I'm attempting to debug a simple PHP script. Essentially, there's a variable which is defined with:

$variable = ($_GET['variable'] == 'true') ? TRUE : FALSE;

Then, in the view file, the following code is meant to display a box if $variable == TRUE:

<? if ($variable == true) { ?>
<p class="box">You have imported a new plan.</p>
<? } ?>

Now, even when that $variable, as shown by var_dump($variable); == FALSE, that HTML is printed between the if { } tags. To me, this defies logic. I simply can't figure out this problem out.

Furthermore, this code works fine on many PHP4 and PHP5 installations except for one particular server running PHP5.2.

Any possible suggestions? Leads? I'm pulling out my hair trying to figure this one out.

Thank you.

© Stack Overflow or respective owner

Related posts about php

Related posts about impossible