title: Use of undefined constant in php
body: <p>don't know better title for this, but here's my code.</p>
  
  <p>I have class user that checks form data when it's instanciated but I get following errors/notices:</p>
  
  <pre><code>Notice: Use of undefined constant username - assumed 'username' in C:\Users\Jinxed\Desktop\WebTrgovina\app\m\Register\User.m.php on line 7
  
  Notice: Use of undefined constant password - assumed 'password' in C:\Users\Jinxed\Desktop\WebTrgovina\app\m\Register\User.m.php on line 7
  
  Notice: Use of undefined constant passwordc - assumed 'passwordc' in C:\Users\Jinxed\Desktop\WebTrgovina\app\m\Register\User.m.php on line 7
  
  ... and so on for every defined variable in user class.
  </code></pre>
  
  <p>Here's the user class:</p>
  
  <pre><code>class User {
      function __construct(){
          $test = 'blah';
          $username; $password; $passwordc; $name; $surname; $address;
          $this-&gt;checkInput(array(username=&gt;20, password=&gt;20, passwordc=&gt;20, name=&gt;20, surname=&gt;40, address=&gt;40));
      }
      //array(formName=&gt;CharacterLimit)
      private function checkInput($fields){
          foreach($fields as $field=&gt;$limit){
              if($_POST[$field]=='' || strlen($_POST[$field])&gt;$limit) $this-&gt;error[] = "$field must be filled in, and it must be less than or $limit characters long.";
              else $this-&gt;{$field} = $_POST[$field];
          }
      }
  }
  </code></pre>
  
  <p>I don't quite understand what's the problem, I've tried first just creating variables and than from the main program calling checkInput method, but I get same error.</p>