|
Posted by Toby Inkster on 01/19/07 16:23
Paul wrote:
> require_once($_SERVER['DOCUMENT_ROOT']."/utility/top.php");
That's not a great way of referencing included files. It makes it
difficult to move your site around.
Try instead creating a directory called "includes", and putting all your
included files into there, like:
includes/search_functions.php
includes/database_functions.php
includes/utility/top.php
includes/utility/bottom.php
includes/utility/left.php
includes/utility/right.php
Now, when you need to refer to them, use:
require_once 'utility/top.php';
Note here that we've not specified the full path for the file, not even a
normal relative path -- we've specified where it is RELATIVE TO THE
"includes" DIRECTORY, not relative to where we are now.
Now in your .htaccess file, you can set:
php_value includes_path /full/path/to/includes/
So when PHP sees a 'include' or 'require' statement, it will search
through the path(s) in the includes_path setting and look for
/full/path/to/includes/utility/top.php.
Yay
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
[Back to original message]
|