I have includes in multiple files, i recently started a new directory and am unable to get some of my includes to work.
for example i have this include in my postpage.php which is located at example.com/c/postpage.php:
The best way, to prevent changes in CWD that might break relative paths is to include files using absolute paths.
An easy way to accomplish this is by using the
serverRoot (/) |-usr |-local |-www |-index.php |-bootstrap.php |-includes |-a.php |-overall |-b.php |-c.php
let's say that:
$basedir = realpath(__DIR__); include($basedir . '/bootstrap.php'); include($basedir . '/includes/a.php');
global $basedir; include($basedir . '/includes/overall/b.php');
global $basedir; include($basedir . '/includes/overall/c.php');