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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:17:56+00:00 2026-06-15T21:17:56+00:00

I am building my first website in PHP. I am testing it locally and

  • 0

I am building my first website in PHP. I am testing it locally and have two computers I am developing it on, my home computer and my Uni computer, with the main project stored in Dropbox.

The project has different root paths on both computers as they have different user names.

‘/home/vadar/Dropbox/ENELWebsite/public_html/’

‘/home/tcpb1/Dropbox/ENELWebsite/public_html/’

This obviously has become a problem as including files using the root path will result in an error on one computer.

I originally tried include this at my index pages, but it also requires a root path for the include file containing it, which I would have to change between computers.

$dir_home = '/home/vadar/Dropbox/ENELWebsite/public_html/';
$dir_uni = '/home/tcpb1/Dropbox/ENELWebsite/public_html/';
if(file_exists($dir_home) OR is_dir($dir_home)){
    define('APP_DIR', $dir_home); //home comp
}
elseif(file_exists($dir_uni) OR is_dir($dir_uni)){
    define('APP_DIR', $dir_uni); //uni comp
}
else{
    echo 'No include directory exists';
}

What is the smartest way to solve this problem? I realise I could just make a new user folder on either one of them, and move the Dropbox folder into it, but I am sure there is a smarter way to include files in the project itself.

  • 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-15T21:17:57+00:00Added an answer on June 15, 2026 at 9:17 pm

    Use $_SERVER[‘DOCUMENT_ROOT’] to find the root folder.

    $dir = $_SERVER['DOCUMENT_ROOT']; // will return /home/vadar/Dropbox/ENELWebsite/public_html/
    if(file_exists($dir)){ //just to make sure
        define('APP_DIR', $dir); //home comp
    }
    else{
        echo 'No include directory exists';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building my first MVC3 website and have connected my site to a mdf
I'm about to begin work on my first ever PHP project -- building a
I'm building a website to learn coding. I have a claim.php which is a
I am building a very small website (with PHP) and I have 2 big
I have a website I'm building with two user streams. I have the code
I'm building an ASP.NET MVC3 website with an code first database and have the
I am building a mobile first website using Susy and would like to have
I have just finished building my first website with a mobile-first responsive design process
I'm building my first website with rails,it consists of a blog, a few static
So I'm building my first ever website with user accounts. What data should I

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.