I'm importing data into a php array from an xml file using SimpleXML.
I'm using the simplexml_load_file
function, but once i've got the data I need, do I need to close the file or similar to clear the memory?
Thanks,
James
No you don't need to do anything with the file. simplexml_load_file()
will close the file internally after it has read the content.
If you take a look at the source code for simplexml_load_file
, you'll see that it is calling the C
function xmlReadFile()
form xmllib2, which in turn will close the file after reading.
PHP_FUNCTION(simplexml_load_file)
{
php_sxe_object *sxe;
char *filename;
int filename_len;
xmlDocPtr docp;
char *ns = NULL;
int ns_len = 0;
long options = 0;
zend_class_entry *ce= sxe_class_entry;
zend_bool isprefix = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|C!lsb", &filename, &filename_len, &ce, &options, &ns, &ns_len, &isprefix) == FAILURE) {
return;
}
docp = xmlReadFile(filename, NULL, options); <--- reading the file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With