What's better of require(dirname(__FILE__).'/'.'myParent.php') than just require('myParent.php')?
Asked 2010-02-08T08:59:55.737
18
Lots of famous PHP scripts including WordPress use dirname(__FILE__).'/myParent.php' instead of just 'myParent.php' when including files in the same directory of the currently running script.
Aren't they the same thing? Why do you prefer typing more?
Using dirname + file name is slightly faster, because PHP will not iterate through include_path searching for the file. If speed matters, you will likely type more.