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 8113683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:54:28+00:00 2026-06-06T02:54:28+00:00

I have a file system structure with symlinks, something like this: folder123 index.php config.php

  • 0

I have a file system structure with symlinks, something like this:

folder123
    index.php
    config.php -> symlink to shared/config.php
shared
    config.php

I run index.php on command line, index.php includes config.php, which is symlink to a file in some other folder.

How can I know index.php file path from the config.php script? The required result is “folder123” (well the full path of it), not “shared”. So, I cannot use __FILE__.

This works on scripts, ran by browser (at least in my case, it is the same as folder123 – the base dir):

$_SERVER['DOCUMENT_ROOT']

I need something for the command-line too.

It looks like

$_SERVER['PWD']

is something what I need, but it’s not documented, so I don’t find it a reliable way. Also, you need to combile it with SCRIPT_FILENAME to get the required results – PWD shows directory, from which the script was run, not it’s full path.

getcwd looks promising, but it can be changed by chdir – I’ll use that if I don’t find some better alternative.

  • 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-06T02:54:31+00:00Added an answer on June 6, 2026 at 2:54 am

    I’m not sure if there is a way to determine what file included a file, but you can get the name of the running program (index.php in this case) with $argv[0], or possibly $_SERVER['argv'][0] if the former is not available.

    //config.php
    //running path
    $path = dirname(realpath($argv[0]));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a XML structure like the following: <Root> <Node Name=File System> <Node Name=C:\Windows\System32\drivers\etc\hosts>
I have a file caching system for a php application. if a file needs
I have an index.html file in my local disk file system on c:\report\index.html .
I have a Lucene Index on a central file system. In my IIS application,
I have a file with the following structure: system.action.webMessage=An error has happened during web
I have a developer tool that modifies the local file system using php. These
I have a file system containing directories of builds, each of which contains a
I have a simple file-system-ed-login (not mysql) just to track number of users who
I have been looking into libraries for a file system that will allow path
I have a requirement to write HTML to the file system and I was

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.