Re: Problems with includes

From: Date: Fri, 16 May 2008 19:28:22 +0000
Subject: Re: Problems with includes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-274440@lists.php.net to get a copy of this message
Tyson Vanover wrote:
I am trying to keep my tools and pages segregated for a variety of reasons (organization, security, etc). And I am having problems with my includes on my LAMP box. My user facing tools are not including my utility classes and files. The root directory of my web server (www.hostname.com/) is: /srv/www/html/ My utility classes and files that need to be included by many of my user tools are in subdirectories of: /srv/www/html/Tools ie /srv/www/html/Tools/tool1/tool1.php /srv/www/html/Tools/tool2/tool2.php included in these sub directories are tool testing pages (toolname-test.php) and other includes. As long as the file that is including other files is in the same directory as the files it is including, it works just fine. My user tools each have their own subdirectories off the webserver root /srv/www/html/ ie /srv/www/html/library/index.php So I would think that to include my utility files into my user tools I would start the file with something like this: require "/Tools/tool1/tool1.php"; require "/Tools/tool2/tool2.php"; But when I do I get: require(/Tools/dbtools/dbtool.php) [function.require]: failed to open stream: No such file or directory /srv/www/html/lib/index.php, line 16 require() [function.require]: Failed opening required '/Tools/dbtools/dbtool.php' (include_path='.:/usr/share/pear') /srv/www/html/lib/index.php, line 16 Am I missing something?
Their are two ways that come to mind. 1. Like Dan suggested, use the full path. 2. (I prefer this way), change your include_path setting either in your php.ini file, virtual host, .htaccess or in your script to include the base path for your web site "/srv/www/html/" and then you can call them by simply removing the leading slash from your existing calls. require 'Tools/tool1/tool1.php'; require 'Tools/tool2/tool2.php'; -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare

« previous php.general (#274440) next »