Search code examples
phppathdocument-root

how to get a path of my working folder in php?


i am new in php. here i have given my project structure and my working folder name is 'Bookings'.

   -Bookings
        +Class
        +lib
        -Public
            -application
               +controller
               +css
               +images
        +frontend

when i used $_SERVER['DOCUMENT_ROOT'] like this :

$path =  $_SERVER['DOCUMENT_ROOT'];
 echo $path;

so obtain output is

D:/xampp/htdocs

so how to get this path "D:/xampp/htdocs/Bookings" in php?

Thanks


Solution

  • define('ROOT', realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR));
    

    you can use

    __FILE__