Welcome to WebmasterWorld Guest from 54.226.246.160

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Managing PHP Includes

     

migthegreek

4:08 pm on Dec 2, 2008 (gmt 0)

5+ Year Member



This is a common question, I know, but I don't understand the solutions that always come up. I want to set the PHP path for an entire site, and never have to ever supply a relative or absolute path to include something, in case the includes path needs to change in future.

Using ini_set seems a bit chicken and egg to me... I would want the include path set before I do anything on my page, then include the header with simply include('header.php') and not worry about the path (same with all other includes from then on).

But if I have to put ini_set at the top of every page on my site, that defeats the point a little, considering I want a globally managed include path that I can set in one place. So then if I put the ini_set in a globally included file... how do I include it without a relative/absolute URL if ini_set has not yet happened?

Is there a solution that allows me to set the includes path somewhere for the entire site, without ever having to then specify include paths later? .htaccess perhaps?

Little_G

5:02 pm on Dec 2, 2008 (gmt 0)

5+ Year Member



Hi,

You may be able to change php settings using .htaccess depending on your server configuration. Take a look at PHP: How to change configuration settings - Manual [php.net]

Andrew

coopster

5:09 pm on Dec 2, 2008 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Welcome to WebmasterWorld, migthegreek.

One of those configuration settings that may be of interest is

auto_prepend_file
.
List of php.ini directives [php.net]

Patrick Taylor

12:40 pm on Dec 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In one of my .htaccess files (at the top) I have (eg):

php_value auto_prepend_file "/path/etc/path/public_html/file.php"

file.php can be anything, I suppose. It gets run on every page load.

g1smd

7:58 pm on Dec 4, 2008 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



See also:

php_value include_path /apache/htdocs/somesite/includes
 

Featured Threads

Hot Threads This Week

Hot Threads This Month