Getting the Contents of a Remote File

Problem

You want to load the contents of a remote file.

Solution

Use the File::getRemote() method.

$contents = File::getRemote($url);

Discussion

If the file cannot be fetched, false is returned.

$contents = File::getRemote($url);
if ($contents === false)
{
    die("Couldn't fetch the file.");
}
comments powered by Disqus