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

nic picture nic · Jan 25, 2012 · Viewed 14.8k times · Source

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

Answer

Mohammad Saberi picture Mohammad Saberi · Jan 25, 2012

You can use dirname($_SERVER['SCRIPT_FILENAME']); to get your current directory for your existing file.