I am currently trying to use the php function \'include\' to include an external url. This is so that whenever the webpage is updated it will automatically update mine. The
Look at your php.ini and make sure allow_url_include is set to 1. Restart HTTPD, done.
You would be better using echo file_get_contents($url)
as the include statement could execute any PHP code returned by the other site.
Look at your php.ini and make sure allow_url_include is set to 1
Otherwise use following ...
function getter($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
return $data;}
echo getter('http://yourdomain.com/externalfile.php');
This will load an external website and also gives external links an absolute website link address
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.your_external_website.com");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
$result = preg_replace("#(<\s*a\s+[^>]*href\s*=\s*[\"'])(?!http)([^\"'>]+)([\"'>]+)#",'$1http://www.your_external_website.com/$2$3', $result);
echo $result
function getter($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
echo getter('http://yourdomain.com/externalfile.php');
And you're done :)