Yes, you are right - dirname(__FILE__)
ensures that the require_once function uses an absolute rather than relative path.
The __FILE__
constant represents the running script. It will return the full path and file name of the running script.
For example, if a script called database.init.php
which is included from anywhere on the filesystem wants to include the script database.class.php
, which lays in the same directory, you can use:
require_once dirname(__FILE__) . '/database.class.php';