I had some problems yonks ago with godaddy and fopen/close
I should have blogged about it then so I hope its still relevant:
lets say we want to source our website:
$website = "http://contact.nexusinternational.jp";
// The following fopen() to fclose() is restricted by godaddy, no problem
require 'HTTP/Request.php';
$r = new HTTP_Request($website);
$r->sendRequest();
$page = $r->getResponseBody();
$c = curl_init($website);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$page = curl_exec($c);
curl_close($c);
$page = '';
$fh = fopen($website, 'r') or die($php_errormsg);
while (! feof($fh)) {
$page .= fread($fh,1048576);
}
fclose($fh);
That just wont work with some security on places like godaddy (like always there is always a workaround).
What is much prettier AND actually works on godaddy is:
// here is our replacement
function getPage($page)
{
$cinit = curl_init();
curl_setopt ($cinit, CURLOPT_URL, $page);
curl_setopt ($cinit, CURLOPT_HEADER, 0);
ob_start();
curl_exec ($cinit);
curl_close ($cinit);
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
$page = getPage ($website);
One Comment
Acually, I recently saw your post, This is very nice and I feel good to see your post. I am always following your blog, Continue posting...
Oracle DBA Training in Chennai
Oracle DBA Course in Chennai
Spark Training in Chennai
Pega Training in Chennai
Oracle Training in Chennai
Social Media Marketing Courses in Chennai
Excel Training in Chennai
Corporate Training in Chennai
Tableau Training in Chennai
Post a Comment