To avoid infinite loops and the warning :
"Warning: feof() expects parameter 1 to be resource, boolean given"
You need to check that the fopen function return the correct type.
This can be achieved very easily with gettype().
Here is an example :
$source = fopen($xml_uri, "r");
$xml = "";
if(gettype($source) == "resource") { // Check here !
while (!feof($source)) {
$xml .= fgets($source, 4096);
}
}
echo $xml;