问题了解dirname文件位置| PHP

I am practicing writing in php and learning about the php syntax. I'm a bit confused about the following function:

function __construct()
{
    require_once dirname(__FILE__) . '/constants.php';
    require_once dirname(__FILE__) . '/DbConnect.php';
    // opening db connection
    $db = new DbConnect();
    $this->conn = $db->connect();

}

When stating require_once dirname(__FILE__) . '/constants.php'; where is constants.php located?

dirname(__FILE__) returns the location of the working file (file in which it is written). Lets say you are on window a d the dir to your working file is C:\myproject\phpfiles\workingfile.php The function dirname(__FILE__) will return C:\myproject\phpfiles Thus your file constants.php should be in the folder phpfiles for your program to find it.

here both files are stored in same location. suppose you are having a file inside c:\xampp\htdocs\test\ called index.php. and the content in the file is require_once dirname(__FILE__) . '/constants.php';. then the file constants.php also located in c:\xampp\htdocs\test\

eg: in your root folder ie. c:\xampp\htdocs\test\ contain two files 1. index.php 2. constants.php