[thelist] PHP includes on Linux vs. Windows

Kelly Hallman khallman at wrack.org
Sat Nov 30 11:51:01 CST 2002


On Sat, 30 Nov 2002, David Bindel wrote:
> When I moved the website that I am hosting over to the Linux partitions,
> I kept getting errors saying that it could not open the files included
> with PHP include() statement. On Windows, I had included them this way,
> and it worked perfectly for all pages of the websites:
>
> <?php include("/includes/included_file.php"); ?>

Considering that this should have looked in your local root directory on
Windows as well.  If you didn't have your include directory in the
system's root directory, I have no idea why it worked. :)

> When I moved the website files over to Linux, all of my include()
> statements were broken because PHP "could not find the file".  After
> doing a search, I found that I could place a "." in front of the first
> "/" to make it check in the current directory, but then I would have to
> change everything to make it relative to the current directory.

Really what you should probably do is remove the initial slash instead.
Though ./ should be congruous.

> My question is this: is it possible to include files from the
> website's root directory relatively (like I had previously done on
> Windows)?

Relatively is ./ or no initial slash.  Preceeding with / is absolute:
would be like saying C:\includes\ vs. simply includes\ ...

> I'm really hoping it's a "yes".

Only thing I can think of is to create a symbolic link from /includes/ to
the directory that has your includes, but that's ugly.  I think the best
thing you could do is fix your absolute references, since they shouldn't
be absolute.

--
Kelly Hallman
http://wrack.org/




More information about the thelist mailing list