I have been banging my head against this one for a while now and have tried many versions of this code. I must be doing something very basic wrong …
$pop = FALSE;
$pop = ($visits > 4);
if ($pop){
drupal_add_js(drupal_get_path('module', 'spester') .'/light.js');
}
var_dump($visits, $pop) gives me
int(3) bool(false)
… and yet the expression inside my if evaluates.
Of course, if I instead do if{FASLE}{...}, then my code behaves as expected …
If that bool is
false, theifbody never gets executed. You can put a simple tracingechothere and you’ll see it.It looks like some other executed code makes you think that the body is executed when in fact it isn’t. Or you editing the wrong file. Or forgot to refresh it. Or something else…
Please don’t blame PHP, you’ll be 99.999% wrong.
Note: I hope FASLE is only a typo in your post. Also, check your warning/error display settings.