define("MY_VARIABLE", true);
and then tried to check if it was defined to true, so:
if(MY_VARIABLE == true)
{
echo 'true';
}
It was ok... until i didn't defined it. Condition still was correct:
// When we remove this line: define("MY_VARIABLE", true);
if(MY_VARIABLE == true)
{
echo 'true';
}
result is still 'true'. We just get notice, but most of php compilations have notices disabled.
Better way is to use string and compare it:
define("MY_VARIABLE", 'true');
if(MY_VARIABLE == 'true')
{
echo 'true';
}
Or use strict condition with tripple =
if(MY_VARIABLE === true)
Now everything will be ok.
Brak komentarzy:
Prześlij komentarz