Page 1 of 1

simplexml_load_file fails inside shutdown function

Posted: Tue Feb 02, 2010 2:28 am
by bnoam
Hello,
I have a script that changes data in xml during its run. In case the user abort somehow (back/stop) I want to write to the XML that it was aborted.

So in the shutdown function I try to open the xml file as usual, but I get this error:

simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: I/O warning : failed to load external entity "uploads/file.xml"

Are there any restrictions in the shutdown function that I should be aware of??

BTW I'm using php 5.2.9

Noam

Re: simplexml_load_file fails inside shutdown function

Posted: Tue Feb 02, 2010 2:54 am
by bnoam
Just found the answer in PHP doc:

If you want to do something with files in function, that registered in register_shutdown_function(), use ABSOLUTE paths to files instead of relative. Because when script processing is complete current working directory chages to ServerRoot (see httpd.conf)