Jump to content

[SOLVED] problem running if statement


DamienRoche

Recommended Posts

I have wrote this simple if statement, along with a nested if statement.

 

if ($var =="yes") {

if($var2 !="" && $var3 !=""){

/////do some stuff

}
}

 

The problem I'm having is that the if statement nested inside the first if statement runs regardless of whether the first statement is satisfied or not.

 

It doesn't make any sense to me because as far as I know it shouldn't even be looking at that code unless the if statement is satisfied.

 

Am I missing something?

Link to comment
https://forums.phpfreaks.com/topic/123561-solved-problem-running-if-statement/
Share on other sites

Sounds like $var does, in fact, equal "yes".

 

$var = "no";
$var2 = "text";
$var3 = "here";

if($var == "yes"){
if($var2 != "" && $var3 != ""){
	echo "It should never get here!";
}
}

 

That code does not echo anything for me.

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.