title: PHP: DOMDocument cannot be found within a class
body: <p>I've got a very weird problem, I have a class named getResources where I want to scrape and extract every CSS location on a $url. Here it is:</p>
  
  <pre><code>class getResources {
      public function getCSSCount($sitename) {
          $count = '0';
          $file = file_get_contents($sitename);
          $doc = new DOMDocument();
          $doc-&gt;loadHTML($file);
          $domcss = $doc-&gt;getElementsByTagName('link');
          foreach($domcss as $links) {
              if( strtolower($links-&gt;getAttribute('rel')) == "stylesheet" ) {
                  $count++;
              }
          }
          return $count;
      }
  }
  </code></pre>
  
  <p>The problem is that DOMDocument cannot be found even though php-xml is installed and working as shown here:</p>
  
  <pre><code>root@robin [~]# php -i|grep DOM
  DOM/XML =&gt; enabled
  DOM/XML API Version =&gt; 20031129
  </code></pre>
  
  <p>I've tested the function by removing it from it's class and parsing via the index.php file directly and it works fine. The problem is that DOMDocument cannot be found if it's within a class. Does anyone know how to fix something like this?</p>
  
  <p>Thanks in advance,
  Alex</p>