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

  • Home
  • SEARCH
  • 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 7848701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:17:48+00:00 2026-06-02T18:17:48+00:00

I need to include a path from a config file in one directory on

  • 0

I need to include a path from a config file in one directory on other scrpits a few directories up or down.

My config file has a function like this:

$execute_path = getcwd() . "/execute.php";

The execute.php file resides in the same directory as the config file wich makes it ok and the output will become:

public-html/config-directory/execute.php

Now if use the same function in a directory that is outside of the original directory, it treats the getcwd() function as if it was in that directory.

For example, if call it from a directory public-html/one/two/three/somefile.php as follow:

<?php 
include(pathto/config.php)
echo $execute_path;
?>

The output becomes publichtml/one/two/three/execute.php rather than staying publichtml/config-directory/execute.php

How can I achieve what I want here? Sorry for the long explanation. Thanks.

  • 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-02T18:17:49+00:00Added an answer on June 2, 2026 at 6:17 pm

    Include can be very tricky why i advice is

    //config.php
    
    define("SITE_PATH", "public-html/config-directory");
    
    
    //execute.php
    
    $execute_path =SITE_PATH . "/execute.php";
    
    //run.php
    include_once 'config.php';
    include_once 'execute.php';
    
    echo $execute_path;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help trying to match a C include file with full path
Using Your Ruby Gem(s) You will need to add /home/username/ruby/gems to the include path.
I'm packaging an ejb and I need to include some .classes from a dependency
Here is my code: //Connect to config file include(dirname(__FILE__)./../config.php); //Connect to the database $db
say i have a file /var/www/foo/test.php how do i find out it's path from
I am moving properties from inside my Spring config file to a separate properties
I need to include some kind of notifications in a sidebar gadget, preferably systray
I need to include a dashboard in a JavaScript application I am building. The
I have a prototype model where I need to include the following extension methods
I've got to modify a C program and I need to include a set

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.