title: Variables not being passed to class method
body: <p>I'm building a login class with PHP, but the variables used are empty when I pass them to the class method even though they shouldn't be.
  I tried returning only the $username variable but it's still empty, though if I return it without using the class I can see that it gets assigned correctly.</p>
  
  <p>I'm using multiple other classes with methods where the variables gets assigned correctly.</p>
  
  <p>I don't know if i've stared myself blind and am missing something obvious or if there's something else causing this.</p>
  
  <pre><code>class Auth
  {
      private $mysqli;
  
      public function __construct(mysqli $mysqli)
      {
          $this-&gt;mysqli = $mysqli;
      }
  
      public function login($username, $password) //These variables are empty, even when they shouldn't be
      {
          $return['error'] = true;
  
          $uid = $this-&gt;getUserId(strtolower($username)); //Returns false because $username variable is empty
  
          if (!$uid) {
              $return['message'] = 'No such user.'; //Output
              return $return;
          }
  
          $user = $this-&gt;getUser($uid);
  
          if (!password_verify($password, $user['password'])) {
              $return['message'] = 'Password incorrect';
              return $return;
          }
  
          $return['error'] = false;
          $return['message'] = 'Logged in';
  
          return $return;
      }
  
      private function getUserId($username)
      {
          $stmt = $this-&gt;mysqli-&gt;prepare("SELECT id FROM users WHERE username = ?");
          $stmt-&gt;bind_param('s', $username);
          $stmt-&gt;execute();
          $stmt-&gt;store_result();
          $stmt-&gt;bind_result($id);
  
          if ($stmt-&gt;num_rows &lt; 1) {
              return false;
          }
  
          $stmt-&gt;fetch();
  
          return $id;
      }
  
      private function getUser($uid)
      {
          $stmt = $this-&gt;mysqli-&gt;prepare("SELECT username, password, email FROM users WHERE id = ?");
          $stmt-&gt;bind_param('s', $uid);
          $stmt-&gt;execute();
          $stmt-&gt;store_result();
          $stmt-&gt;bind_result($username, $password, $email);
  
          if ($stmt-&gt;num_rows &lt; 1) {
              return false;
          }
  
          $stmt-&gt;fetch();
  
          $return['uid'] = $uid;
          $return['username'] = $username;
          $return['password'] = $password;
          $return['email'] = $email;
  
          return $return;
      }
  }
  </code></pre>
  
  <p>A form assigns the variables sent.</p>
  
  <pre><code>&lt;form method="POST" action="post.php"&gt;
      &lt;label&gt;Username
      &lt;input style="display:block;width:250px;" type="text" name="username" required&gt;&lt;/label&gt;
      &lt;label&gt;Password
      &lt;input style="display:block;width:250px;" type="password" name="password"&gt;&lt;/label&gt;
      &lt;button style="display:block;" class="default_btn"&gt;Log in&lt;/button&gt;
  &lt;/form&gt;
  
  if (isset($_POST['username'])) {
      $username = $_POST['username'];
      $password = $_POST['password'];
  
      $auth = new Auth($mysqli);
      $auth-&gt;login($username, $password);
  
      if ($auth-&gt;login()['error']) {
          echo 'error:' . $auth-&gt;login()['message'];
      } else {
          echo 'success:' . $auth-&gt;login()['message'];
      }
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>If I assign the variables in the class method the code works:</p>
  
  <pre><code>public function login($username = 'user', $password = 'pass')
  </code></pre>
  
  <p>But if I do this, it will not work:</p>
  
  <pre><code>$username = 'User';
  $password = 'pass';
  
  $auth = new Auth($mysqli);
  $auth-&gt;login($username, $password);
  </code></pre>
  
  <p>Also, if I use the $_POST values outside of $auth->login() they are assigned so they are not empty when passing them to the class...</p>