Jump to content

[SOLVED] Includes path...


BuckeyeTheDog

Recommended Posts

Hello all, 

 

1)  Can I set a subdirectory path for an includes file??    As in, when my main php file is on the root can I "include" my server login file from a subdirectory?  If so, currently I'm not having luck doing it...  Here's a sample...

 

include("/public_html/phptest/AbConnect.php");

in which public_html is my ftp webserver directly, phptest is a subfolder and AbConnect.php is the file with the login info.

 

If I can do this, how do I do it?  Or do I need the included file in the same directory?

 

2)  When/if I have PHP and HTML files in a subdirectory and you want to have an "includes" file, do you just place it in that same subdirectory, or can you/ how would you reference a different subdirectory- or go up the path to the root???

 

 

Thanks for your help...

Link to comment
https://forums.phpfreaks.com/topic/114537-solved-includes-path/
Share on other sites

1) Try: include("public_html/phptest/AbConnect.php"); Instead of: include("/public_html/phptest/AbConnect.php")

2) To go up a dirctory use ../    so if you were in the "phptest" directory and wanted to go up to the "public_html" directory you would type ../newDirectory . if you are down two directories from root and want to go back to root simply type "../../newDirectory". You can put include files anywhere, just make sure you call them with the correct path. Use "require" instead of "include" as a way of testing to see if the included file is found. If you use require, the page won't load at all and you'll know that the page you wanted to include wasn't found.

Link to comment
https://forums.phpfreaks.com/topic/114537-solved-includes-path/#findComment-588997
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.