title: Loading external library into ExpressionEngine plugin
body: <p>I'm trying to load an external library into an ExpressionEngine plugin but am getting:</p>
  
  <p><em>Message: Undefined property: Detector::$EE</em></p>
  
  <p>In the plugin itself I've got:</p>
  
  <pre><code>public function __construct()
  {
      $this-&gt;EE-&gt;load-&gt;library('detector');
      $this-&gt;EE =&amp; get_instance();
  }
  </code></pre>
  
  <p>and my folders are set up like:</p>
  
  <p>detector<br>
  -libraries<br>
  --Detector.php<br>
  -pi.detector.php</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Having moved past the loading library error, I'm now getting an 'undefined variable' error with the following code:</p>
  
  <pre><code>public function detector()
  {
   return $ua-&gt;ua;
  }
  
  public function user_agent()
  {
  return $ua-&gt;ua;
  }
  </code></pre>
  
  <p>That's if I have {exp:detector:user_agent} in my template. If I {exp:detector} I get no output.</p>