title: PHP How to access variable from other variable inside class?
body: <p>Here is my class:</p>
  
  <pre><code>&lt;?php
  class myClass {
      private $a = 1;
      private $b = array(
          'a' =&gt; $this-&gt;a
      );
  
      public function getB() {
          return $this-&gt;b;
      }
  }
  
  $myclass = new myClass();
  var_dump($myclass-&gt;getB());
  </code></pre>
  
  <p>I want to access variable $a in variable $b. But this shows this error:</p>
  
  <blockquote>
    <p>( ! ) Parse error: syntax error, unexpected '$this' (T_VARIABLE) in
    C:\xampp\htdocs\test1.php on line 5</p>
  </blockquote>