title: PHP - Private class variables giving error: undefined variable
body: <p>I am getting the error "Undefined variable: interval in C:\wamp\www\DGC\classes\DateFilter.php"</p>
  
  <p>Here is my code for the DateFilter class:</p>
  
  <pre><code>class DateFilter extends Filter
  {
      //@param daysOld: how many days can be passed to be included in filter
      //Ex. If daysOld = 7, everything that is less than a week old is included
      private $interval;
  
      public function DateFilter($daysOld)
      {
          echo 'days old' . $daysOld .'&lt;/ br&gt;';
          $interval = new DateInterval('P'.$daysOld.'D');
      }
  
  
      function test()
      {
          echo $interval-&gt;format("%d days old &lt;/br&gt;");
          //echo 'bla';
      }
  
  }
  </code></pre>
  
  <p>When I create a new instance of the DateFilter class and call test() it give me the error. I realize it means the variable hasn't been initialized, but I know that the constructor is being called because I put an echo statement in there and it was output.</p>
  
  <p>I have also tried:
  $this::$interval->format(...);
  self::$interval->format(...);
  but it didn't work.</p>
  
  <p>I know this is probably an easy fix, sorry for the noob question. Can't believe this stumped me.</p>