Least code to confirm false condition

Whats a shorter way to code this?


if (isset($tbl_key2) == FALSE) {

}

Conditional logic is one of those things that looks simple enough but can present problems if you don’t understand exactly what it’s doing.

if (“conditional statement evaluates to true”){ do_something(); }

There are several “flavors” of “true” and “false”.

If you need to ensure an exact boolean false you need to use ===

Variable and function returns can be “false” in different ways i.e. boolean false, empty string “”, numeric 0

The docs and experience debugging will be your better teacher, but for your example consider what [fphp]isset/fphp returns

If a variable has been unset with unset(), it will no longer be set. isset() will return FALSE if testing a variable that has been set to NULL. Also note that a NULL byte (“\0”) is not equivalent to the PHP NULL constant.

So your asking
if the expression “is $tbl_key2 equal to null?” then the if test is true.

Depending on what your variable is and what your doing you may be able to simplify with a “not” - “!”

Thanks mitteneague for your great explanation. It has the answer I needed.

Niche