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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:27:48+00:00 2026-05-10T21:27:48+00:00

In HTML, I can find a file starting from the web server’s root folder

  • 0

In HTML, I can find a file starting from the web server’s root folder by beginning the filepath with "/". Like:

/images/some_image.jpg 

I can put that path in any file in any subdirectory, and it will point to the right image.

With PHP, I tried something similar:

include("/includes/header.php"); 

…but that doesn’t work.

I think that that this page is saying that I can set include_path once and after that, it will be assumed. But I don’t quite get the syntax. Both examples start with a period, and it says:

Using a . in the include path allows for relative includes as it means the current directory.

Relative includes are exactly what I don’t want.

How do I make sure that all my includes point to the root/includes folder? (Bonus: what if I want to place that folder outside the public directory?)

Clarification

My development files are currently being served by XAMPP/Apache. Does that affect the absolute path? (I’m not sure yet what the production server will be.)

Update

I don’t know what my problem was here. The include_path thing I referenced above was exactly what I was looking for, and the syntax isn’t really confusing. I just tried it and it works great.

One thing that occurs to me is that some people may have thought that "/some/path" was an "absolute path" because they assumed the OS was Linux. This server is Windows, so an absolute path would have to start with the drive name.

Anyway, problem solved! 🙂

  • 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. 2026-05-10T21:27:48+00:00Added an answer on May 10, 2026 at 9:27 pm

    What I do is put a config.php file in my root directory. This file is included by all PHP files in my project. In that config.php file, I then do the following;

    define( 'ROOT_DIR', dirname(__FILE__) ); 

    Then in all files, I know what the root of my project is and can do stuff like this

    require_once ROOT_DIR.'/include/functions.php'; 

    Sorry, no bonus points for getting outside of the public directory 😉 This also has the unfortunate side affect that you still need a relative path for finding config.php, but it makes the rest of your includes much easier.

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

Sidebar

Ask A Question

Stats

  • Questions 272k
  • Answers 272k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer $('#login_btn').click(function(){ $("#message").text("button was pushed"); return false; }); return false to… May 13, 2026 at 1:53 pm
  • Editorial Team
    Editorial Team added an answer You don't need to pass in the ID. Just traverse… May 13, 2026 at 1:53 pm
  • Editorial Team
    Editorial Team added an answer Update - I've redone my answer because, after a half-night's… May 13, 2026 at 1:53 pm

Related Questions

In HTML, I can find a file starting from the web server's root folder
I've been staring at this one for a while and I'm completely stumped. You'll
In writing some tests for a project I'm working on, I found that the
I bought the O'Reilly Dojo book by Matthew Russell. It says in your toolkit
I'm using eclipse for a few months, I realy like gvim better but eclipse

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.