I am working on an inherited website and just switched everything to php7. I have been finding lots of errors due to this switch. One error is that the function simplexml_load_file() is not returning anything. I pass it a variable that has been set to a file path on our server (i.e. /dir/dir/dir/template.xml). But when this function gets called it doesn't return any value, neither the object we want nor a 0 to indicate it failed.
I am not experienced in php so I am having a hard time figuring out what has gone wrong. I checked the file template.xml for errors in an online checker and none were found. I checked that the file path is correct but I'm wondering if the format of /dir/dir/dir/template.xml is wrong. All of the examples of this problem I have seen deal with a url rather than a local file.
The exact line of code is:
$xml = simplexml_load_file($TempleteXml) or die("Unable to load configuration data!");
And I have already tried breaking it down to be sure die() is not the problem.
Edit: I have found another place in the code where this problem occurs. It is another file where the same type of file is called in the exact same way.
Edit: I finally was able to get an error that tells me what is happening. The problem is: "Uncaught Error: Call to undefined function simplexml_load_file()..." So for some reason it doesn't know where to find that file even though on NetBeans I am able to see exactly where it is declared. I will look into this line of inquiry next.
Edit: So it turned out that this is a common problem. For some reason when updating to php7.0 SimpleXML is not installed (which is the extension where this function lies). I found that out here: PHP 7 simpleXML But when I do this initially "php -m" shows SimpleXML is listed as enabled, however when I restart apache2 SimpleXML then disappears. Does anyone know why a php module would disappear on restart?