简体   繁体   中英

“../” (back directory) not working on PHP in Windows

I have no clue why it's not working but when I go to debug my code it doesn't work and just throws an error like this:

Fatal error: require(): Failed opening required '../classes/John/settings.php' (include_path='.;C:\xampp\php\PEAR')

Directory Structure: http://gyazo.com/220cf2d603f8f1267260b2dd72d2d46d

You shouldn't be performing includes relative to the current directory. What if you wanted to move that file? All of the links would break. A way to ensure that you can still link to other files, while retaining those links if you move your file, is: require_once($_SERVER['DOCUMENT_ROOT'] . 'directory/directory/file');

DOCUMENT_ROOT is a server variable that represents the base directory that your code is located within.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM