Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8011959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:10:44+00:00 2026-06-04T19:10:44+00:00

this is very simple but very confusing most times.. i need to know what

  • 0

this is very simple but very confusing most times..

i need to know what it means by when we include files by following patterns (where i have seen in many places may be there is more than this)

What it means ?

"./path" 

"/path"

"../path"

dirname(__FILE__)

basename(dirname(dirname(__FILE__)));

require dirname(__FILE__) . DIRECTORY_SEPARATOR;

pathinfo()

define('BASE_PATH',realpath('.'));

define('BASE_URL', dirname($_SERVER["SCRIPT_NAME"]));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:10:45+00:00Added an answer on June 4, 2026 at 7:10 pm

    “./path”

    The dot refers to the working directory. This is the directory printed when you type “pwd” on the command line. This may be the directory of the script itself, or the directory of the script that is run first, but not always.

    “/path”

    Paths that begin with a slash are relative to the topmost directory. This is usually the root directory of the server, but it can also be a mount point, your user directory, or maybe your web root depending on how the server is configured.

    “../path”

    “..” refers to the directory which is one level above the working directory. So if the working directory is /foo/bar then “..” is “/foo” and “../path” refers to “/foo/path”

    dirname(__FILE__)

    dirname() “Returns parent directory’s path.” __FILE__ is a magic constant that refers to the full path of the file that uses it. So if you have a script at /foo/bar/baz/file.php, __FILE__ will be “/foo/bar/baz/file.php” and, dirname(__FILE__) will be “/foo/bar/baz”

    basename(dirname(dirname(__FILE__)));

    basename() “Returns trailing name component of path”. Same rules apply for dirname(), so while dirname(__FILE__) in the previous example is “/foo/bar/baz” dirname(dirname(__FILE__)) would be “/foo/bar”. The trailing component of this path is “bar”, so for this __FILE__ , basename(dirname(dirname(__FILE__))) would be “bar”.

    require dirname(__FILE__) . DIRECTORY_SEPARATOR;

    DIRECTORY_SEPARATOR is a constant I didn’t know about, but apparently it is defined in a file system extension. If __FILE__ is “/foo/bar/baz/file.php” then the path comes out to be “/foo/bar/baz/”. So this statement seems to be incomplete. require() is like include() except that it gives an error if the file can’t be found. The path never refers to a file, so this statement doesn’t make much sense.

    pathinfo()

    pathinfo() parses a path. Pass it a path, and it will give an associative array containing dirname, basename, extension, and filename keys with respective pieces of the parsed path.

    define(‘BASE_PATH’,realpath(‘.’));

    realpath() will take a relative path and morph it into an absolute path. As stated earlier, “.” refers to the working directory, and if that is “/foo/bar/baz” then realpath(“.”) will return “/foo/bar/baz”. define() will make a constant, so this has the effect of setting the BASE_PATH constant to the working directory of the script. This could be useful if the working directory changes in the course of the script, or if you are including files in subdirectories they can use the constant to refer to the top level of the web application with it.

    define(‘BASE_URL’, dirname($_SERVER[“SCRIPT_NAME”]));

    Same deal with define() and dirname(). The new thing here is $_SERVER[“SCRIPT_NAME”]. If the address the script is loaded from is example.com/foo/file.php then this will be “/foo/file.php” and dirname() of that is “/foo”. Setting this constant could be useful for pages in the web app to refer to each other.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably very simple but it's really confusing me. When I implement the
This may be very simple question,But please help me. i wanted to know what
I know this is probably a very simple question but how would I do
I'm sure this is very simple. I have gotten colorbox to work before, but
This seems like it should be very simple but I can't get it to
I'm sure this is a very simple fix but I cannot seem to find
I was making this very simple lex program (just an introductory program). But on
This looked like a very simple question but I couldn't find the answer. How
This is a very simple question, but I can't seem to find something about
This should be very simple, but I'm blocking on this.... Let's say, for the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.