Assume that we have the following directory structure:
Document Root
Now, Assuming that we want to call file(1-5).php in index.php which is in DirectoryB, we can use the following approach:
Contents of index.php:
<?php include($_SERVER['DOCUMENT_ROOT'].'/../DirectoryA/file1.php'); include($_SERVER['DOCUMENT_ROOT'].'/../DirectoryA/file2.php'); include($_SERVER['DOCUMENT_ROOT'].'/../DirectoryA/file3.php'); include($_SERVER['DOCUMENT_ROOT'].'/../DirectoryA/file4.php'); include($_SERVER['DOCUMENT_ROOT'].'/../DirectoryA/file5.php'); ?>
In the above example, $_SERVER gets the DOCUMENT_ROOT asset in the configuration for the given site and then performs actions relative to it, i.e.: /../ takes to the parent folder and then we add the relative path to file.
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Now, Assuming that we want to call file(1-5).php in index.php which is in DirectoryB, we can use the following approach:
Contents of index.php:
In the above example, $_SERVER gets the DOCUMENT_ROOT asset in the configuration for the given site and then performs actions relative to it, i.e.: /../ takes to the parent folder and then we add the relative path to file.
need an explanation for this answer? contact us directly to get an explanation for this answer