title: php - Call to a member function find() on a non-object simple html dom
body: <p>I want to get html code from a website ,I'm using this code to do so but I'm getting this error :
  Call to a member function find() on a non-object </p>
  
  <p>this is the code:</p>
  
  <pre><code>include_once('simple_html_dom.php');
  
  $fileEndEnd = mb_convert_encoding("http://www.yjc.ir/fa/news/5192798/%D8%B3%DB%8C%D8%B3%DB%8C-%D8%AE%D9%88%D8%A7%D8%B3%D8%AA%D8%A7%D8%B1-%D8%AA%D9%88%D9%82%D9%81-%D8%AD%D9%85%D9%84%D8%A7%D8%AA-%D9%87%D9%88%D8%A7%DB%8C%DB%8C-%D8%B9%D8%B1%D8%A8%D8%B3%D8%AA%D8%A7%D9%86-%D8%A8%D9%87-%DB%8C%D9%85%D9%86-%D8%B4%D8%AF", 'HTML-ENTITIES', "UTF-8");
  
  $c=curl_init($fileEndEnd);
  curl_setopt( $c, CURLOPT_USERAGENT,'nginx-curl-blahblahblah' );
  curl_setopt( $c, CURLOPT_RETURNTRANSFER, true );
  $r=curl_exec( $c );
  curl_close( $c );
  
  $html = str_get_html($r);
  foreach($html-&gt;find('div.body') as $e)
      $a= $e-&gt;outertext . '&lt;br&gt;';
  </code></pre>
  
  <p>the error is on this line :</p>
  
  <pre><code>foreach($html-&gt;find('div.body') as $e)
  </code></pre>
  
  <p>I'm sure the $r variable has the html code, I echo $r and get the full html code. </p>
  
  <p>What am I doing wrong ?</p>
  
  <p>thanks </p>