title: PHP - Nested IF statements
body: <p>What control structures can one use instead of multiple nested IF statements.</p>
  <p>eg:</p>
  <pre><code>function change_password($email, $password, $new_password, $confirm_new_password)
  {
      if($email &amp;&amp; $password &amp;&amp; $new_password &amp;&amp; $confirm_new_password)
      {
          if($new_password == $confirm_new_password)
          {
              if(login($email, $password))
              {
                  if(set_password($email, $new_password))
                  {
                      return TRUE;
                  }
              }
          }
      }
  }       
  </code></pre>
  <p>This function is used like this:</p>
  <pre><code>if(!change_password($email, $password, $new_password, $confirm_new_password)
  {
      echo 'The form was not filled in correctly!';
      exit;
  }
  </code></pre>
  <p>I call all my functions like this, and I'm wondering if there's something wrong with my coding style. I'm having my doubts because if I follow this design then that means every single function I write will just be with nested with IF's, checking if there are errors at every stage. Is this what other people do?</p>
  <p>I don't see many other scripts written like this, with the nested IF's making a triangle shape and only having the desired result in the very middle. If the middle isn't reached, then something screwed up.</p>
  <p><strong>Is this a good function structure?</strong></p>