I'm trying to call simplexml_load_file with the $url parameter being another .php file which will then make some calculations, and after that, it will "echo" a string containing the xml code.
It looks something like this:
$urlrequest= $_SERVER['DOCUMENT_ROOT']."/generateXML.php?id=5&output=xml";
$xml = simplexml_load_file($urlrequest);
where generateXML.php will be something like:
<?php
//do some random code
$aux= '<?xml version="1.0" encoding="UTF-8" ?>';
$aux.= "<item>";
$aux.= "<name>John</name>";
$aux.= "<location>somewhere</location>";
$aux.= "</item>";
echo $aux;
?>
The problem is, if generateXML.php is located at a remote ip it will work fine, but when the file is located in the same server, the i get the "failed to load external entity" error.
I have found out that the problem may come from the parameters in the url. For example:
$var1=file('dosomething.php'); works fine
but $var1=file('dosomething.php?id=1'); returns "failed to open stream" error
I need to be able to add those parameters to the url, is there any way of doing it?