I am trying to write a function that includes a file named header.php in a helper file in Code Igniter.
// loads the header
function loadHeader() {
require_once('../views/templates/header.php');
}
However, PHP issues the error
Message: require_once(../views/templates/header.php) [function.require-once]: failed to open stream: No such file or directory
I then tried to make the address relative to the view that is calling loadHeader().
// loads the header
function loadHeader() {
require_once('templates/header.php');
}
However, this function also produces a similar error. What is the address relative to? Is there a convenient way for me to find out the relative path from which PHP is including a file?
There are a few ways to do this:
Standard View Loading:
Absolute Include:
Relative Include: