title: Simple HTML DOM - Failed to open stream: Connection Timeout
body: <p>Hello I hosted my website into a free hosting site (5gbfree.com) and I created here a function where it retrieves the Peso-dollar rate based from the site <a href="http://ppa.com.ph??q=fcer_view" rel="nofollow noreferrer">http://ppa.com.ph??q=fcer_view</a> where it simply select the <code>a.active</code> element and get the value as plaintext. It was working yesterday but when I checked it our again this morning it failed to fetch. So it will return the default value which is 50.</p>
  
  <p>error_log:</p>
  
  <pre><code>[09-Apr-2017 13:49:32 Asia/Manila] PHP Warning: file_get_contents(http://www.ppa.com.ph/?q=fcer_view): failed to open stream:     Connection timed out in /home/rasibaseport/public_html/simple_html_dom2.php on line 75
  </code></pre>
  
  <p>I am using simple html DOM.
  Here's the function. </p>
  
  <pre><code>include "simple_html_dom2.php";
  
  function PPA_peso_dollar_rate(){
  // Create DOM from URL or file
  error_reporting(E_ALL);
  ini_set("display_errors", 0);
  ini_set('default_socket_timeout', 15);
  $html = file_get_html("http://www.ppa.com.ph/?q=fcer_view");
  $ret = 0;
  if($html === false){
      $ret = 50;
  }else {
      foreach($html-&gt;find('a[class=active]') as $e) 
      $ret = $e-&gt;plaintext;
      $explode = explode(" ", $ret);
  
      $ret = 50;
      foreach($explode as $ex){
          if(is_numeric($ex)){
              $ret = $ex;
          }
      }
      if($ret == 0) $ret = 50;
  }
  
  echo $ret;
  }
  </code></pre>
  
  <p>Unfortunately 5gbfree disabled curl_init() function.</p>
  
  <pre><code>curl_init() has been disabled for security reasons in /home/rasibaseport/public_html/config.php on line 38
  </code></pre>
  
  <p>Is there any work a round here? I appreciate any help. Thank you very much.</p>
  
  <p><strong>Edit:</strong> I forgot to mention that testing this with localhost(xampp), the expected return value is correct with no errors and warnings. Works perfectly fine.</p>
  
  <p><strong>UPDATE:</strong> After trying @Rafiq's updated solution, nothing worked. It gave me similar error.</p>
  
  <pre><code>[09-Apr-2017 20:18:53 Asia/Manila] PHP Warning:  file_get_contents(http://www.ppa.com.ph/?q=fcer_view): failed to open stream: Connection timed out in /home/rasibaseport/public_html/simple_html_dom2.php on line 46
  </code></pre>