title: Initializing object properties - how to do it properly
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1157201/initializing-class-fields-at-the-field-definition-or-in-class-contructor">Initializing Class Fields at the Field Definition or in Class Contructor</a><br>
    <a href="https://stackoverflow.com/questions/1484265/setting-variables-on-constructor-vs-on-the-class-definition">Setting variables on Constructor VS on the class definition</a>  </p>
  </blockquote>
  
  
  
  <p>What is the difference (if any) between the following 2 examples, and what is the proper way to initialize object properties?
  Please note that the content of $fields in this case is something predefined, it will not change in runtime.</p>
  
  <p>Example 1:</p>
  
  <pre><code>class User
  {
      $fields = array('username', 'password', 'email');
  
      function __construct()
      {
      }    
  }
  </code></pre>
  
  <p>Example 2:</p>
  
  <pre><code>class User {
      $fields;
  
       function __construct()
       {
           $this-&gt;fields = array('username', 'password', 'email');
       }     
  }
  </code></pre>