title: PHP OOP - using an object inside other classes
body: <p>I've been a php programmer for a number of years, but am only now getting into OOP. I have two classes so far, Item and List (I'm just simplifying here, they're not the real class names.) All of my data is accessed via a web service using SOAP. </p>
  
  <p>I'm not sure what the best way is to implement getting a SOAP client and using it in multiple classes. For example, the WSDL defines an addItem function and a getList function. I also need to send a token to the service for each transaction.</p>
  
  <p>Do I need to define a new SoapClient inside every class? like so:</p>
  
  <pre><code>class Item {
    // item properties
    function addItem($itemName) {
       $client = new SoapClient('myfile.wsdl');
       $client-&gt;addItem($itemName);
       //service returns true or false
    }
  }
  
  class List {
    function getList($listName) {
       $client = new SoapClient('myfile.wsdl');
       return $client-&gt;getList($listName);
       //service returns array
    }
  }
  </code></pre>
  
  <p>Or is there some way to create a new SoapClient outside of the individual classes and use the same client object in each one?</p>