note 16492 added to function.include
| From: | mthornton at wei dot cc | Date: | Thu, 01 Nov 2001 21:15:39 +0000 |
| Subject: | note 16492 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-20016@lists.php.net to get a copy of this message | ||
Here is the best fix for relative includes on *nix that I've found. Don't do them!
Instead, create your mysite.com/includes dir and put all your includes in it. Then make a root level
dir, like /www, set permissions so that only the webserver can use it. Inside that make a symbolic
link with a unique name like /www/mysite_includes that points to mysite.com/includes.
Now you can access your includes by
include_once('/www/mysite_includes/my_file_to_include.php'); which points to
mysite.com/includes/my_file_to_include.php. notice that it's slash (/) www which is your root
level directory.
This is very useful for servers with many domains where each site includes a lot of files. The
symbolic link lets you keep your includes close to the directories of the rest of your code, yet
allows you to access them abosolutely at the root dir level.
It's probally a good idea to write in the headers of the files that use this that it is using
the smbolic link.
--
http://www.php.net/manual/en/function.include.php
http://master.php.net/manage/user-notes.php?action=edit+16492
http://master.php.net/manage/user-notes.php?action=delete+16492
http://master.php.net/manage/user-notes.php?action=reject+16492