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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:55:15+00:00 2026-06-04T15:55:15+00:00

I have a problem with my include path. I am trying to build a

  • 0

I have a problem with my include path. I am trying to build a cms but I want to build it so that not all the files need to be in the root for the including.

Link To File Structure

I am trying to include from anywhere to an other file. But the problem is that I include files in other files.

Like:
I include ErrorHandling in T_ErrorLog
But i use A textfile in Textfiles in ErrorHandling so that path isn’t correct.

Errors:

Notice: Undefined variable: error in C:\Users\Kevin\Desktop\Dropbox\Programming\Webdesign\Workspace\KLJ Peer\GhostCMS\TestFiles\T_ErrorLog.php on line 7
Test

Warning: fopen(/GhostCMS/Textfiles/ErrorLog.txt) [function.fopen]: failed to open stream: No such file or directory in C:\Users\Kevin\Desktop\Dropbox\Programming\Webdesign\Workspace\KLJ Peer\GhostCMS\Core\ErrorHandling.php on line 15
can't open file

T_ErrorLog.php

<?php

include_once ('../Core/ErrorHandling.php');

use Core\ErrorHandling;

ErrorHandling::HandleError("Test", $error);

ErrorHandling.php

namespace Core;

class ErrorHandling {
    public static function HandleError($errorMessage, $error){
        echo $errorMessage . "<br />";
        echo "Indien dit zicht blijft voor doen.<br />";
        echo "Zal de webmaster dit ontvangen en even kijken naar het probleem!<br />";

        ErrorHandling::WriteToErrorFile($errorMessage, $error);
    }
    public static function WriteToErrorFile($errorMessage, $error){
        $myFile = "/GhostCMS/Textfiles/ErrorLog.txt";
        $fh = fopen($myFile, 'a') or die("can't open file");

        $today = date('j/n/Y - H:i:s');
        fwrite($fh, "Error: \n");
        fwrite($fh, "Date: " . $today . "\n");
        fwrite($fh, "User error message: " . $errorMessage . "\n");
        fwrite($fh, "System error message: " . $error . "\n");
        fwrite($fh, "--------------------------------------------------\n");
        fclose($fh);
    }
}

Is there some way to make the include path relative for al the directories???

  • 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-04T15:55:17+00:00Added an answer on June 4, 2026 at 3:55 pm

    Well you know your file structure and it won’t really change. Generally speaking you have a few options: record the root directory or starting point from where to derive your other files to include with options like DIR or FILE PHP Magic Constants

    e.g. you could have saved FILE upon install or in your bootstrap file and then just adapt directories to derive from that path.

    $myPreviouslySavedPath = __DIR__   // e.g. /home/user/meme/www/
    fopen($myPreviouslySavedPath . '/GhostCMS/Textfiles/ErrorLog.txt') // would then be /home/user/meme/www/GhostCMS/Textfiles/ErrorLog.txt 
    

    Alternatively for php includes php has an autoloader, which is just a function you supply yourself, where you let that function decide where to load the specific file from.
    This is something you’d set in the entrypoint of your CMS and would probably combine with the base directory you collected.

    e.g.

    spl_autoload_register('myClassLoader');
    
    function myClassLoader($class){
         // << here you'd place logic to decide the best path for your file >>
         include(__DIR__ . "/classes/$class");
    }
    

    The main thing to remember and use is that you have a fixed entrypoint for your application and you know the location of that file. Therefrom you can deduce the logical path of all other files.

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

Sidebar

Related Questions

I have encountered the strange problem, that linux c++ compiler includes the files from
I have problem with fancybox. I want to write a function that will run
I have the following code: #include <iostream> #include Student.h <-- fixed the problem #include
My problem: require_once '/includes/aws-sdk-1.5.2/sdk.class.php'; My environment: I have a pretty standard PHP site that
i have problem with autorotate on iphone i set up in all classes -
I have an android application which uses jni and I'm trying to automate build
I'm new to C and trying to recurse through all directories/files from the current
I've been trying to get this code to work for hours! All I need
We have in one of our applications a single eclipse project that contains all
I have an Objective C static library that I am trying to import into

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.