| Tony Marston 2004-07-25, 8:55 am |
|
"steve" <UseLinkToEmail@dbForumz.com> wrote in message
news:10g5ct6bktt76bd@news.supernews.com...
> I am quite frustrated with php's include, as I have spent a ton of
> time on it already... anyone can tell me why it was designed like this
> (or something I don't get)?
>
> The path in include is relative NOT to the immediate script that is
> including it, but is relative to the top-level calling script.
EXACTLY! That is the way it was designed to work and the way it has been
working for many years. If all the other PHP developers can live with it
then why can't you?
> In practice, this means that you have to constantly worry and adjust
> paths in includes, based on the startup scripts that call these
> lower-level scripts.
I certainly don't. I have several applications which exist in their own
directory, so each top-level script starts in one of these directories. If I
want to include() another file it must either exist in the directory of the
current top-level script, or it must exist in one of the directories
specified on the include_path entry in the php.ini file. If I specify
'./sub/filename.php' in an include() then that is relative to the directory
of the current top-level script. If this were changed in PHP to be relative
to the current include() file then would break a huge number of existing
scripts.
> Why is the include path not simply relative to the script that is
> immediately including?
I suggest you change your approach to one that reflects the way that PHP
actually works. Trying to force PHP to do what it was not designed to do and
then bitching about it is not a sensible idea.
--
Tony Marston
http://www.tonymarston.net
|