in Education by
I'm sure I'm missing some simple explanation, but I want to confirm - so assume I know very little. I have a directory structure like so (for the time being) of: My main site (localhost/project/ on my testing server, and C:/xampp/htdocs/project on my HDD) with these files and folders: Root graphics variousgraphics.png support stylesheet.css templates header.php footer.php initialize.php you default.php index.php anotherfile.php Up until I created the folder 'you' everything was fine, i.e. I included the initialize file for index.php as <?php include(templates/initialize.php) ?> But when I decide to include initialize.php using the above method for the default.php file (inside 'you'), it errored out with Warning: include(templates/initialize.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\photoquilt\you\default.php So naturally I appended ../ to create <?php include(../templates/initialize.php) ?> but then of course that didn't work because the files referenced inside initialize.php weren't appended in the same way, and so I get to here. It's worth noting for me, an echo of $_SERVER['document_root'] leads to C:/xampp/htdocs So in summary: Is there any way to make sure all the link/paths work correctly irrespective of where the originating path was from? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
In default.php you can define a constant like define('ROOT_PATH', dirname(__DIR__)); or for php versions prior to 5.3.0 define('ROOT_PATH', dirname(dirname(__FILE__))); and then use ROOT_PATH in all scripts to build the the file paths. see - http://docs.php.net/language.constants.predefined - http://docs.php.net/dirname

Related questions

0 votes
    I'm sure I'm missing some simple explanation, but I want to confirm - so assume I know very ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    What do you do to check broken links in an application?...
asked Oct 19, 2020 in Technology by JackTerrance
0 votes
    In Ruby, Dir.glob("**/*.rb") (for instance) doesn't traverse symlinked directories. Is it ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I am creating a script on the fly to ftp some files from a remote computer. I create a file ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I am creating a script on the fly to ftp some files from a remote computer. I create a file ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I am new at using Ansible. I tried to create directories and download files using Ansible. Should I use shell ... module is available? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    It takes effort to copy files and directories from a USB drive or OneDrive to the local drive, work with and ... or a remote system? Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    What is the important directories used in a common Laravel application?...
asked Sep 28, 2021 in Technology by JackTerrance
0 votes
    The parameter in sqoop which specifies the output directories when importing data is A - --output-path B - --target-path C - --output-dir D - --target-dir...
asked Jan 13, 2021 in Technology by JackTerrance
0 votes
    Software built as microservices can, by definition, be broken down into multiple component services. A. True B. False...
asked Jan 9, 2023 in Technology by JackTerrance
0 votes
    How can you fix a broken commit? A. git reset B. git commit –amend C. git fix D. git rebase...
asked Dec 23, 2022 in Technology by JackTerrance
0 votes
    After a Chrome update (73.0.3683.75), my flex rendering is completely broken. The issue is known and discussed ... n°X article n°X article n°X article n°X article n°X article n°X...
asked May 7, 2022 in Education by JackTerrance
0 votes
    What would happen if the protective tin coating over an iron bucket is broken in some places ? Select the correct answer from above options...
asked Jan 5, 2022 in Education by JackTerrance
0 votes
    Which of the following animals can regenerate it's broken body part? 1. Cockroach 2. Frog 3. ... ,Science proposed by,electromagnetic theory engineering physics,Science nptel...
asked Nov 7, 2021 in Education by JackTerrance
0 votes
    The blobs are broken into smaller pieces using which of the following functions? (a) partition() (b) ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 22, 2021 in Education by JackTerrance
...