Jump to content

[SOLVED] if construct using isset


tcpa41

Recommended Posts

Hello,sry if it is a dumb question,but im trying to write an if construct which usses isset and my problem is that i  want it to execute only if isset is false.

 

My idea looks like this,but when it's executed i get error about unexpected false.So how do i make such construct work only incase $val is false?

if(isset($val)))==false
{
}

Link to comment
https://forums.phpfreaks.com/topic/162266-solved-if-construct-using-isset/
Share on other sites

Hello,sry if it is a dumb question,but im trying to write an if construct which usses isset and my problem is that i  want it to execute only if isset is false.

 

My idea looks like this,but when it's executed i get error about unexpected false.So how do i make such construct work only incase $val is false?

if(isset($val)))==false
{
}

 

It's a syntax error.  You simply need:

if(!isset($val))
{
   /* code */
}

 

The '!' is a logical NOT, so the expression literally says "If $val IS NOT set, execute the following code."

 

EDIT: Remember also that checking to see if a value is set is NOT the same as checking whether it's value is false.

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.