note 40934 deleted from function.dirname by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 19:07:51 +0000 |
| Subject: | note 40934 deleted from function.dirname by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142273@lists.php.net to get a copy of this message | ||
Note Submitter: zippy wonder idiot at yahoo dot com
----
Andrew,
There are certainly good reasons to use relative includes, though I agree they usually should not be
used exclusively. Here's a couple of common situations:
1) You do not have control over the web server on which you're developing. If you want your
pages to work even if your {ISP,employer,friend,etc.} rearranges their server -- particularly
Apache's user_dir -- then relative includes are the way to go. Your pages will work if
they're at "http://www.host.tld/~user/", "http://host.tld/user/", or even "http://user.host.tld/".
2) You are developing a script or set of scripts for distribution. You don't want to force
your users to rearrange their web server to allow includes from /includes/my-files before they can
use your script, after all.
On my own server, for example, I keep all site-wide PHP and JavaScript in /scripts so that I
don't have to worry about where they're being called from. The include files used by my
media library, however, are in a scripts subdirectory of the folder the main script runs in. This
also makes development easier; the development and production versions simply reside in different
folders, allowing them to use different versions of the include files without altering the include
statements.