[thelist] PHP includes (how to call from subdir)

Garrett Coakley garrett at polytechnic.co.uk
Mon Dec 9 05:48:01 CST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, 7 Dec 2002 10:18:04 -0500 j.d. welch wrote:

> sure, you can do it like that, but i think it's worth mentioning that
> you can change the include_path directive per directory. in an
> .htaccess file in your DocumentRoot, add something like:
>
> php_value include_path=".:/path/to/my/includes:/some/other/path"


Another method, if you have a self contained app is to define some
constants in a master configuration file that outline your directories
and then just include the config file in each of the application files.

So an example based on Aleems situation:

config.php
- ---
define(PUBLIC_ROOT, '/path/to/public_html');
- ---

index.php (any of them)
- ---
require(/root/path/to/config.php); // include config file
include(PUBLIC_ROOT . 'template.php');
- ---

That way, if you decide to rebuild the app, move the directory structure
around, or add in any new constants you only have to set them in
config.php and the rest of the files will automatically pick up the
changes.

G.



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)

iD8DBQE99IUT4AAXt40rqS4RAp9sAKDJU3Vb/KJ6tQDU/NCV/pOqiYz7OACeIPy5
zGyf1ZYnVog+IO+NWmpGqnk=
=xadp
-----END PGP SIGNATURE-----



More information about the thelist mailing list