title: PHP - Set class variable from another class variable within same class?
body: <p>I'm trying to set up a PHP class:</p>
  
  <pre><code>class SomeClass {
      private $tags = array(
          'gen1' =&gt; array('some string', 1), 
          'gen2' =&gt; array('some string', 2), 
          'gen3' =&gt; array('some string', 3), 
          'gen4' =&gt; array('some string', 4), 
          'gen5' =&gt; array('some string', 5), 
      );
  
      private $otherVar = $tags['gen1'][0];
  }
  </code></pre>
  
  <p>But this throws the error:</p>
  
  <blockquote>
    <p>PHP Parse error:  syntax error, unexpected '$tags'</p>
  </blockquote>
  
  <p>Switching it to the usual...</p>
  
  <pre><code>private $otherVar = $this-&gt;tags['gen1'][0];
  </code></pre>
  
  <p>returns the same error:</p>
  
  <blockquote>
    <p>PHP Parse error:  syntax error, unexpected '$this'</p>
  </blockquote>
  
  <p>But accessing the variable within a function is fine:</p>
  
  <pre><code>private $otherVar;
  
  public function someFunct() {
      $this-&gt;otherVar = $this-&gt;tags['gen1'][0];
  }
  </code></pre>
  
  <p>How can I use the previously defined class variable to define and initialize the current one, without an additional function?</p>