I have a file structure as follows:
>project
>admin
>classes
>class_main.php
>templates
>foot.php
Within class_main.php, I am trying to use require_once
to require the same file, dependent on where the user is (ie, if the user is in the admin dir, require_once "../templates/foot.php"
otherwise require_once "./templates/foot.php"
) inside of the __destruct function of my class.
My problem is that no matter what I try, I am always receiving the same error:
Warning: require_once(C:\wamp\www\project\classes/templates/foot.php) [function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\project\classes\class_main.php on line 22
I have tried:
- using require_once as a function
- using
dirname(__FILE__)
and__DIR__
- using
\
and\\
instead of/
How can I do this?
The full code of the __destruct function at the moment is:
function __destruct()
{
if($this->admtrim($_SERVER['PHP_SELF']) == 'admin')
{
require_once "../templates/foot.php";
}
else
{
require_once './templates/foot.php';
}
}
To clarify, this script is located at C:\wamp\www\project\classes\class_main.php
and the file I am trying to include is located at C:\wamp\www\project\templates\foot.php
.