Forum Moderators: coopster

Message Too Old, No Replies

performance of the include files

placement vs performance of the include files

         

Tastatura

9:27 pm on Feb 14, 2006 (gmt 0)

10+ Year Member



Hi all,
I have a question in regards to placement and performance of the include files (if the question has been answered before please point me in the right direction, as I wasn’t able to find it).
I am on shared hosting running Apache 1.3, and PHP 5

I have my.html page located in ../html_public/ Dir /SubDir/. That page calls my includeme.php file. I know that I can place “includeme.php” in SubDir and everything will work fine, however because the way I want to organize my files/directories I don’t want to put it there. That same “includeme.php” file is called by other html pages that are in different directories and subdirectories, hence I would like to put it in some centralized location (maybe ../html_public/myscripts/ or something to that effect).

Now if I put the “includeme.php” in the centralized location, and if I call it from my.html page, what is the best way to do this, i.e. least performance penalty for loading the my.html page?
Would it be:

include "../../../includeme.php";
or
include “mydomain.com/myscripts/includeme.php”;
or
configuring php.ini file (exactly what and how; also would I have to include the php.ini file in all dirs where .php files reside)

or
?

Thanks a lot

DrDoc

9:35 pm on Feb 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In your main .htaccess file (inside html_public/Dir/SubDir), add the following line:

php_value include_path ".:/full/path/to/folder/html_public/myscripts/"

Now, PHP will always look in the local folder first. Then, if not found, look in your myscripts folder.

You can even, if you want, remove the initial ".:" portion to completely disallow includes in the local folder.

Tastatura

11:14 pm on Feb 14, 2006 (gmt 0)

10+ Year Member



Hi,
Thanks for the info. I tried and this is what I got after I checked to see if the changes were reflected in the .htaccess file (I am on shared hosting with no access to the box)

# File modified on Tue Feb 14 16:07:42 2006 by server
# For security reasons, mod_php is not used on this server. Use a php.ini file for php directives
# php_value include_path ".:/this/was/full/path/"

any other suggestions?

coopster

5:20 pm on Feb 15, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Tastatura.

Bummer. Luckily though, this particular directive can be overridden per script. It isn't the ideal setup, but when you are using shared hosting that is just how it is.

ini_set() [php.net]

Be sure to follow the link to the 'appendix' on that page as well, you'll need to refer to this page of the manual more often than you would imagine.

Tastatura

4:21 pm on Feb 16, 2006 (gmt 0)

10+ Year Member



Thanks a lot - good info