title: php using curl to get the html and save it on a txt
body: <p>I've been learning to program in PHP and i am trying to make a PHP script with CURL instead file_get_contents($url)</p>
  
  <p>The reason that i want to learn more about Curl is because it is faster and more flexile but more harder</p>
  
  <p>So, i am coding this to download the HTML code from some URL and save it on a TXT</p>
  
  <pre><code>$ch = curl_init();
  
  curl_setopt($ch, CURLOPT_URL, "http://www.google.pt");
  curl_setopt($ch, CURLOPT_HEADER, 0);
  
  //should save html in $html
  $html = curl_exec($ch);
  
  //save html on txt
  $fh = fopen('html.txt', 'w') or die("can't open file");
          fwrite($fh, $html);
          fclose($fh);
  
  curl_close($ch);
  </code></pre>
  
  <p>But instead, curl_exec(); return 1 and print the code on my page</p>
  
  <p>is there anyway to do what i want?</p>