[UPHPU] include() outside root
Dan Wilson
dan at acucore.com
Tue Feb 1 09:43:05 MST 2005
> Is there a way to include() a file outside the document root from a
> file that is referenced in several files, each in a different level of
> the directory?
The __FILE__ constant and dirname() are your friends.
include (dirname(__FILE__) . '../path/file.php');
So for your example:
> /root/website/backend.php
> <? include(../config.php); ?>
include(dirname(__FILE__) . '/../config.php');
So now config.php will always be found. Basically this is making
relative paths work by translating them into absolute paths.
-Dan
More information about the UPHPU
mailing list