title: Trouble getting source code from a webpage
body: <p>I've written a script in <code>php</code> to get the html content or source code from a webpage but I could not succeed. When I execute my script, it opens the page itself. How can I get the html element or source code?</p>
  
  <p>This is the script:</p>
  
  <pre><code>&lt;?php
  include "simple_html_dom.php";
  function get_source($url)
  {
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      $htmlContent = curl_exec($ch);
      curl_close($ch);
      $dom = new simple_html_dom();
      $dom-&gt;load($htmlContent);
      return $dom;
  }
  $scraped_page = get_source("https://stackoverflow.com/questions/tagged/web-scraping");
  echo $scraped_page;
  ?&gt;
  </code></pre>
  
  <p><strong><em>Currently I'm getting like this:</em></strong></p>
  
  <p><a href="https://i.stack.imgur.com/keI7F.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/keI7F.jpg" alt="enter image description here"></a>
  <strong><em>My expected output is something like:</em></strong></p>
  
  <p><a href="https://i.stack.imgur.com/uCvU5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uCvU5.jpg" alt="enter image description here"></a>
  <strong><em>Btw, <code>echoing $htmlContent</code> also gives me what you can see in image 1.</em></strong></p>