simplexml_load_file fails inside shutdown function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bnoam
Forum Newbie
Posts: 5
Joined: Sun Jan 24, 2010 5:58 am

simplexml_load_file fails inside shutdown function

Post 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
bnoam
Forum Newbie
Posts: 5
Joined: Sun Jan 24, 2010 5:58 am

Re: simplexml_load_file fails inside shutdown function

Post 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)
Post Reply