title: Dealing with "PHP HTML DOM Parser", including the same library into two different files
body: <p>I have two PHP files (same folders) that access the library <code>simple_html_dom.php</code></p>
  
  <p>The first one, <code>caridefine.php</code>has this:</p>
  
  <pre><code>include('simple_html_dom.php');
  $url = 'http://www.statistics.com/index.php?page=glossary&amp;term_id=209';
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $curl_scraped_page = curl_exec($ch);
  libxml_use_internal_errors(true);
  $dom = new DomDocument();
  $dom-&gt;loadHtml($curl_scraped_page);
  $xpath = new DomXPath($dom);
  print $xpath-&gt;evaluate('string(//p[preceding::b]/text())');
  </code></pre>
  
  <p>The second one, <code>caridefine2.php</code> has this:</p>
  
  <pre><code>include('simple_html_dom.php');
  $url = 'http://www.statsoft.com//textbook/statistics-glossary/z/?button=0#Z Distribution (Standard Normal)';
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $curl_scraped_page = curl_exec($ch);
  
  $html = new simple_html_dom();
  $html-&gt;load($curl_scraped_page);
  foreach ($html-&gt;find('/p/a [size="4"]') as $font) {
      $link = $font-&gt;parent();
      $paragraph = $link-&gt;parent();
      $text = str_replace($link-&gt;plaintext, '', $paragraph-&gt;plaintext);
      echo $text;
  }
  </code></pre>
  
  <p>Separately, each of them worked fine, I ran the <code>caridefine.php</code>, it worked well, so did the <code>caridefine2.php</code>.
  But when I tried to load these two files in other PHP files:</p>
  
  <pre><code>        &lt;div class="examples"&gt;
              &lt;?php
                  $this-&gt;load-&gt;view('definer/caridefine.php');
              ?&gt;
          &lt;/div&gt;
  
          &lt;div class="examples"&gt;
              &lt;?php
                 $this-&gt;load-&gt;view('definer/caridefine2.php');
              ?&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>None of them worked. Just gave me a blank page, when I pressed <code>CTRL+U</code>, it said: <code>Cannot redeclare file_get_html() (previously declared in C:\xampp\htdocs\MSPN\APPLICATION\views\Definer\simple_html_dom.php:70) in C:\xampp\htdocs\MSPN\APPLICATION\views\Definer\simple_html_dom.php on line 85</code></p>
  
  <p>I googled for this problem, I found that "if you load many objects without clearing the previous ones, it can be a problem."
  I've tried doing <code>$html-&gt;clear()</code> and <code>unset($dom)</code>. It gave me nothing.
  What is it that makes me like in the end of the line?</p>
  
  <p>Thanks..</p>