I confused about how forward slash work in php. Is it return the web root? Or computer files root? Or something else?
I tried several things, for example, my file structure in ubuntu server is like this:
/var/www/html/domainname.com/. --/config/. --/core.php --/images/. --/includes/. --/footer.php --/header.php --/navigation.php --/index.php This is work (all of them included in index.php):
<img src="/images/logo.png" /> # in header.php <a href="/">Home</a> # in navigation.php <a href="/test/test.php">test</a> # in index.php itself This doesn't work:
<?php require_once('/config/core.php'); ?> <?php include_once('/includes/header.php');?> <?php include_once('/includes/navigation.php');?> <?php include_once('/includes/footer.php');?> Why the last four examples doesn't work? The "/" character should returns domainname.com right? Or it returns "/var/www/html/" instead?
My goal is to put all files that needed to be included in includes directory. So, every .php file can access them relatively even if the .php file stored in sub directory.
..index.phpcase, it wil return/var/www/html/like that?include_pathsettings, if you start with/it will start looking on thatinclude_pathsetting. in your case its../to move one level back from where your script is running/is always/. And/is root folder. For UNIX OS its.../! For Windows, it's usuallyC:, but sometimes apache will return your access folder. To be sure, always use relative paths.