Jump to content

how does php determine what if an else applies to?


Hailwood

Recommended Posts

The else goes with the previous if() that is at the same 'nested' statement level.

 

For what you posted, the else is at the same statement level as the if($c==$d).

 

To force the the else in the code you posted to go with the if($a==$b) test, you need to enclose the $c==$d logic inside of {} so that it becomes a single statement that is part of the if($a==$b) test -

if($a==$b){
if($c==$d)
return true;}
else
return 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.