Forum Moderators: coopster
Working on Linux, I created this script:
---
$url = "http://www.mydomain.com";
$html = @file_get_contents($url, "r") or die("Can't open URL");
echo $html;
-----
This script:
- works ok on my PC box (PHP 4.4.5) with 'http://www.google.com'
- works ok on my PC box (PHP 4.4.5) with 'http://www.mydomain.com'
- works ok on my server (PHP 4.4.2) with 'http://www.google.com'
- DOES NOT work on my server (PHP 4.4.2) with 'http://www.mydomain.com'
Does anybody have any tip to find out why I can't read 'http://www.mydomain.com' on my server? Must I modify something on my 'mydomain.com' server (I manage it)?
Thank you very much.
error_reporting(E_ALL);
$url = "http://www.mydomain.com";
$html = file_get_contents([url=http://us2.php.net/manual/en/function.urlencode.php]urlencode[/url]($url)) or die("Can't open URL");
echo $html;
Yes, and in fact it doesn't have to be a URI, either. You can just have a relative path:
/path/to/file.html.