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.
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???