I have simplexml_load_file instruction placed withing included PHP file. But this instruction works depending on where I include this file from. Why? Is it possible to make relative file path be interpreted relatively to the file instruction placed in?
I have simplexml_load_file instruction placed withing included PHP file. But this instruction works depending
Share
You can always access the current file’s full path with the magic __FILE__ constant, so you can write your simplexml_load_file() call like this:
Update
Since PHP 5.3, there have been a new
__DIR__introduced, you can use it in place of thedirname(__FILE__)like this: