i know my question seems a bit vague but an example will do wonders.
For example :
When you go into a folder you use : <?php include_once 'includes/header.inc.php' ?>
when you want to go back one you use ../../ to go back you get the idea. However is there by chance a better way of doing this cuz i’ve found it’s easy to break?
vague but i hope someone can help, thanks in advance.
I’ve obviously tried the ../ to go back to parent directory or folder. When i google i tend to find how to go back using header etc but i dont think that’ll help me much.
>Solution :
Use your DOCUMENT_ROOT
as the starting point for all your includes
and requires
… That way it will be portable between dev and production as well.
Here you can read about $_SERVER
IE
include_once $_SERVER["DOCUMENT_ROOT"] . '/public/foo/bar/includes/header.inc.php';