Re: order of include on include()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, June 14, 2006 3:23 pm, blackwater dev wrote:
> If I have a file:
>
> /code/folder1/test.php
>
> and in that file, it has these includes:
>
> include_once("../../file1.php");
> include_once("../../file2.php");
> include_once("../../file3.php");

../ is just gonna give you headaches, sooner or later.

Just fix your include_path and be done with it.

> I then have another file:
>
> /code/test2.php
>
> That file pulls in test.php.
>
> include_once("folder1/test.php");
>
> Why do I get errors on the includes?

I don't think include_once is THAT smart...

Or maybe it just assumes you are using include_path in a sane way and
not doing this in the first place... :-)

include and include_once have nothing to do with the current file.

They ONLY look at your include_path.

Your include_path MIGHT (and probably should, in many applications)
have '.' as one of the directories in it.

But even then, I believe '.' simply means current working directory,
so unless you are dinking around with http://php.net/chdir (which you
probably shouldn't, usually) then it's just gonna be the ONE directory
of the very first PHP file loaded, no matter where all the other files
are.

Hope that helps.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux