Re: Includes and paths problem
| From: | Monty | Date: | Fri, 18 Apr 2003 22:18:20 +0000 |
| Subject: | Re: Includes and paths problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-144443@lists.php.net to get a copy of this message | ||
Here's how I do it. You can create sub-directories within the include
directory, so, if your php.ini statement looks like this:
include_path = /blah/blah/includes
You can create a sub-directory named after your project in "includes" and
put all the include files in there:
/blah/blah/includes/project
If in the above directory you have a script named func.php, you load it this
way in the script:
include_once('project/func.php');
Any scripts that are to be accessible to ALL sites can simply be put in the
/blah/blah/includes directory.
The only other way to do this without keeping track of your paths is to put
all included scripts in the /includes directory, but, preface the filename
with the site:
amazon_func.php
yahoo_func.php
etc.
Monty
> From: odcs@rogers.com (C.R.)
> Newsgroups: php.general
> Date: Fri, 18 Apr 2003 17:42:11 -0400
> To: "PHP General" <php-general@lists.php.net>
> Subject: Includes and paths problem
>
> Is their a proper way to include files so that the paths are always correct.
> I have a login script as well as protected pages - and the protected pages
> may be accessed from many possible locations on the site - the included
> files may also have other included files - so what I have now is a real
> mess. I'm constantly getting errors saying could not find this file or that
> file. Is there a way I can make sure these files are available from
> anywhere. Using an include directory works for some files, but I can't put
> my whole site in there.
>
> Any suggestions are appreciated.
>
> C.R.
>
>
>