title: PHP functions within class -- call function within class
body: <p>I have an interface like this:</p>
  
  <pre><code>interface General {
      public function getFile($file);
  
      public function searchFile($to_search);
  }
  </code></pre>
  
  <p>I have a class, like so:</p>
  
  <pre><code>class Parent implements General {
  
  
      public function getFile($file) {
         $loaded = file($file);
     }
  
      public function searchFile($to_search) {
      $contents = $this-&gt;getFile(); // doesn't work because I need the $file from get_file()!
      // searches file
      // returns found items as collection
      }
  }
  </code></pre>
  
  <p>Then in the code, I can do something like....</p>
  
  <pre><code>$file = "example.txt";
  $in = new Parent();
  $in-&gt;getFile($file)
  $items = $in-&gt;searchFile('text to search');
  foreach($item as $item) {
      print $item-&gt;getStuff();
  } 
  </code></pre>
  
  <p>All the examples I have seen to reference another function within a class don't take an argument.</p>
  
  <p>How do I reference the $file from getFile($file) so that I can load the file and start searching away? I want to implement it through the interface, so don't bother changing the interface.</p>