title: PHP code won't execute with specific variable
body: <p>Here is my code:</p>
  
  <pre><code>class FormValidator {
  
      private $firstname;
      private $lastname;
      private $email;
      private $fields_with_lengths = array('first' =&gt; 2, 'last' =&gt; 2);
      private $color = '&lt;span style="color:#FF0000"&gt;';
  
      function checkFirst($firstname) { 
          $first_error = NULL;
          if(strlen(trim($firstname)) &lt; $this-&gt;fields_with_lengths['first']){
              $first_error = $this-&gt;color . 'Please enter more than ' . $this-&gt;fields_with_lengths['first'] . ' characters.&lt;/span&gt;';
          }
          return $first_error;
      }
  
      function checkLast($lastname) {
          $last_error = NULL;
          if(strlen(trim($lastname)) &lt; $this-&gt;fields_with_lengths['last']){
              $last_error = $this-&gt;color . 'Please enter more than ' . $this-&gt;fields_with_lengths['last'] . ' characters.&lt;/span&gt;';
          }
          return $last_error;     
      }
  
  
  
      function validateEmail($email){
          return preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $email);
      }
  
  
  }
  </code></pre>
  
  <p>Here is where I call it:</p>
  
  <pre><code>$validator = new FormValidator();
                  $firstResult = $validator-&gt;checkFirst($_POST['firstname']);
                  $lastResult = $validator-&gt;checkLast($_POST['lastname']);
                  $emailResult = $validator-&gt;validateEmail($_POST['emailaddress1']);
  
                  if (is_null($firstResult) &amp;&amp; is_null($lastResult) &amp;&amp; $emailResult) {
  
                      $mail = new PHPMailer();
  
                      $mail-&gt;IsSMTP();  // telling the class to use SMTP
                      $mail-&gt;AddAddress("s...@....com");
  
                      $mail-&gt;Subject  = "test";
                      $mail-&gt;MsgHTML($messageHTML);
  
                      redirectULS('english/forms/thankyou.php');
  
                      if(!$mail-&gt;Send()) {
                          echo 'Message was not sent.';
                          echo 'Mailer error: ' . $mail-&gt;ErrorInfo;
                      } else {
  
                          //$bridge-&gt;pushLead($lead);
                      }
                  } 
  </code></pre>
  
  <p>This only works if I remove $emailResult from the if statement.  What am I doing wrong.  I'll take into account the earlier comments about functions that only return true or false later.  Right now I need to fix this if statement.  Thanks.  (Some variables are set elsewhere.  All I want to know here is how to get the if statement to work.)</p>