Need help with php includes

software development

#1

I have a couple of questions and I am hoping some one can help me. I want to have all my includes files in one folder in one place above my domain name (so it cant be accessed by anyone on the web) so this is what i want to know…

what is the best way to do this. Should I do this by editing the php.ini or should i just write out an the full includes path so it goes to a folder above my domain and if I can do that what would the code be to have it point to an include folder above the domain.


#2

You can create a sub directory in your user directory that may contain PHP includes, on the same tree level as your website directories:

/home/username/includesYou can then include a PHP file from your new directory with code like this:

<?php include("/home/username/includes/example.php"); ?>
si-blog
Max discount on any plan with promocode SCJESSEYTOTAL


#3

i do pretty much exactly this, but instead of putting in the whole path, i use a relative path:

require_once dirname($_SERVER[‘DOCUMENT_ROOT’]) . ‘/includes/example.php’;

that way if you move hosts (why would you want to do that?) and your document root changes, you don’t have to edit all your php files

track7 - my dream-hosted site


#4

I do exactly the same thing, but that is not what the original poster asked for. The OP wanted to know the actual path.

si-blog
Max discount on any plan with promocode SCJESSEYTOTAL


#5

thanks you both have been a big help and have told me exactly what i needed to know.