Jump to content

[SOLVED] if(!$variable)


sgtbash

Recommended Posts

Check the PHP Comparison Operators in the manual. With that read, it will make more sense.

 

Basically, an if statement evaluates the clause to true or false. Throwing the '!' on the front practically switches the outcome of the statement. So, in that case, you are checking to see that the $variable evaluates to false. If so, then the statement is executed.

Link to comment
https://forums.phpfreaks.com/topic/49338-solved-ifvariable/#findComment-241767
Share on other sites

AHAR!!!!

 

Thanks

 

I figured it was something to do with NOT as i use the if(* != *) function all the time but was unaware you could use it to check it that quickly.

 

Thanks

 

Dan

 

You can use it to invert almost any phrase, too, which can get confusing rather quickly:

<?php
function returnFalse() {
  return FALSE;
}

if (!(returnFalse() !== FALSE)) // Evaluates to TRUE every time
{

}
?>

Link to comment
https://forums.phpfreaks.com/topic/49338-solved-ifvariable/#findComment-243604
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.