title: double semicolon in dangling else in php
body: <p>i have started learning php and i saw a piece of code in php documentations that was bug reported but in the report page said that was not a bug.
  the code is :</p>
  
  <pre><code>$bar = 'bar';
  $foo = 'foo';
  
  if (isset($bar)):
     if (isset($foo)) echo "Both are set.";
  elseif (isset($foo)):
     echo "Only 'foo' is set.";
  else:
     echo "Only 'bar' is set.";
  endif;
  </code></pre>
  
  <p>if we put the nested if code in curly braces again that error is happening.</p>
  
  <pre><code>if (isset($bar)) :
      if (isset($foo)) {  
             echo "Both are set.";
      }
  elseif (isset($foo)) :
         echo "Only 'foo' is set.";
  else :
         echo "No one is set.";
  endif;
  </code></pre>
  
  <p>the above code raise an error unexpected ":" and the reason of report page said this it is not a bug it was the mixed structure used in above code and php does not allowed and i accepted that but what makes this code go wrong.
  but why if we add another semicolon at the end of nested if statement it works perfectly.
  or why if we add else statement at the end of nested if statement error will gone.
  something like this :</p>
  
  <pre><code>if (isset($bar)) :
      if (isset($foo)) {  
             echo "Both are set.";
      } else {
              echo "this is else";
      }
  elseif (isset($foo)) :
         echo "Only 'foo' is set.";
  else :
         echo "No one is set.";
  endif;
  </code></pre>
  
  <p>i will appreciate if anyone help i know this mixed structure is really bad but understanding the problem will help to prevent another mistakes.
  thanks a lot;</p>