homepage Welcome to WebmasterWorld Guest from 54.166.66.204
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Managing PHP Includes
migthegreek




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

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




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

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




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

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




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

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




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

See also:

php_value include_path /apache/htdocs/somesite/includes

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved