Reputation: 3061
How to get the currently executing directory of the currently executing file? This needs to return the currently executing file's directory even if the file is included by another file. I landed on this:
$dir = str_replace(basename(__FILE__),"",__FILE__);
But is there a more straightforward way?
Upvotes: 0
Views: 128
Reputation: 547
To get the directory of the file I use the dirname function like this :
$dir = dirname(__FILE__);
Upvotes: 4