[thelist] PHP includes on Linux vs. Windows

Rich Gray rich at f1central.net
Sat Nov 30 12:13:01 CST 2002


David

It seems in your case that windows decided absolute paths as starting in the
web site document root! Whilst linux correctly interprets the absolute path
to be from the root directory of the server... There were a few bugs with
absolute paths in some Win32 versions of PHP so I'd say you were lucky that
it worked at all on windows!

You can include relative to the document root but not with a leading slash -
you can tweak your include_path directive in your php.ini file to have a '.'
in your include path then the current directory will be searched. So
include('includes/included_file.php') should work if the including script is
located in the directory above the includes directory... however you will
need to get rid of the leading slash in all your scripts.

Cheers
Rich

-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of David Bindel
Sent: 30 November 2002 09:09
To: thelist at lists.evolt.org
Subject: [thelist] PHP includes on Linux vs. Windows



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I have recently "migrated" to a dual-boot system with Slackware Linux
and Windows 2000 Server.  Last night on the Linux partition I
finished configuring Apache with PHP.  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"); ?>

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.

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

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


Thanks,

David Bindel




More information about the thelist mailing list