Results 1 to 4 of 4

Thread: How to get the directory path of the current PHP file / script?

  1. #1
    Administrator Kavoir's Avatar
    Join Date
    Dec 2009
    Posts
    183

    How to get the directory path of the current PHP file / script?

    To get the local path of the currently running PHP file / script, just use this in the file:

    Code:
    dirname(__FILE__)
    __FILE__ is an inherently changing constant of PHP that contains the path of the current running PHP script, function dirname() distills and returns the directory path of any file path. It's a handy way of getting the current working directory within PHP code.

  2. #2
    Administrator Kavoir's Avatar
    Join Date
    Dec 2009
    Posts
    183
    So to print out the directory of the currently running PHP script:

    Code:
    echo dirname(__FILE__);

  3. #3
    Really nice postings are both.Thanks for these useful postings.

  4. #4
    Junior Member
    Join Date
    Mar 2011
    Posts
    1
    thanks a lot for that posting, i am a PHP learner, this posting will help me most.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •