I’ve the datastructure of the first image.
The code below is from Class.CIBootstrap.php
And as you can see, on the 4th line i do:
require 'Class.CIAjaxHandler.php';
and that works fine. Now, if it’s not an ajax I want to load the proper controller…
This does NOT work. As you can see from the structure CIAjaxHandler is in the same folder as the CIBootstrap, but the CILoginController that I try to access isnt, but why cant I access it via
require '../controllers/Class.CILoginController.php' ?


It could be a good idea define absolute path. Because:
So, simply include a constant file where you can generate cascade of path like so:
and in your scripts
In this case you are absolute sure what you include, and WHERE is the file that you want include.
Suppose you’ve this structure:
/root.php
/index.php
/path1/path1.php
In this case if you call
/path1/path1.phpthe script works, because include root.php in parent folder and it’s ok.But if you call
/index.phpit does not works, because the inclusion file is already relative to parent folder.So, if in your software you plan to call different files in different locations, use constants COULD be one solution.
Another solution could be set an include path or to specify always an absolute path with
__DIR__at start of relative path.