It could be a good idea define absolute path. Because:
- Files/Folders could change location in the future
- Prevent issues like your question (the parent file could not be the same for different call)
- If you look the code, you know where you should find the files
So, simply include a constant file where you can generate cascade of path like so:
define('PATH_ROOT' ,__DIR__.'/'); define('PATH_CLASSES' , PATH_ROOT.'classes/'); // ...
and in your scripts
require_once PATH_CLASSES.'controller/Class.CIAjaxHandler.php';
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
<?php echo "Hello World";
/index.php
<?php include 'path1/path1.php';
/path1/path1.php
<?php include '../root.php';
In this case if you call /path1/path1.php the script works, because include root.php in parent folder and it's ok. But if you call /index.php it 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.
controllersfolder?