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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:11:01+00:00 2026-06-07T02:11:01+00:00

I have a home.php file which references fileA using php require command which is

  • 0

I have a home.php file which references fileA using php require command which is in the same folder i.e. localhost. the code is:

<?php // /localhost/home.php
require ('/fileA.php');
?>

fileA references another file in its code fileB.
so far its workin properly
when i access fileC.php
i reference fileA using

<?php // /localhost/A/B/fileC.php
require ('../../fileA.php');
?>

the code is able to acquire fileA but only works properly when fileB is in the same folder as fileC else produces a 404 error.I am not able to understand why is this happening since fileB is called by fileA.

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-07T02:11:04+00:00Added an answer on June 7, 2026 at 2:11 am

    When using relative file paths, keep in mind that they are relative to your current working directory, not to file that performs inclusion. current working directory is set automatically on the first request (A/B in your case).

    Some simple solutions: always use dirname(__FILE__) before including file, this way it be relative to the file the is in:

    <?php 
    require(dirname(__FILE__)."/FileA.php"); 
    require(dirname(__FILE__)."/../../FileB.php"); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file which name is load.php near index.php in root folder. So
I have an htaccess file which maps http://www.myserver.com/home/ to http://www.myserver.com/index.php?section=home This part works fine.
I have been trying to create an XML using the simplexml library (v2.6.2) http://simple.sourceforge.net/home.php
I have folder home/admin. In this folder there is index.php. When i access to
I have HTML tidy extension on my home computer using PHP 5.2.11 (Windows -
I'm using the following command to execute a PHP file via cron php -q
I have executed my php program which requires DB.php file. While executing the php
I have a file called init.php which I want to get automatically included in
I have a study logout.php file which works fantastically, the issue I am faced
I have an HTML form which submits values to the following PHP file, which

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.