includes on Linux and Windows

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a program that performs an
include("/home/xyz/includes/common.php"); I do this so the include file
(which contains database login information) is outside of the web root
directory and (hopefully) invisible to anyone who might get into the
website. On my home PC running XP and Apache, my PHP.ini include_path
is set to ".;d:\xampp\includes\" and under this directory I have the
directories "home\xyz\includes". This worked fine when running on my
old system using PHP 4.2.2. I recently upgraded to the latest version
of Xampp running PHP 5.0.5 and I now cannot access the include files on
my XP system. If I change the include to remove the leading "/", it
works fine - but will not work on Linux. I understand that this used to
work on older version of Win32 PHP but has been changed.  Is there a
way to issue an include that will work on both Linux and XP under the
more recent versions of PHP?

Many thanks.  ---Jim

Re: includes on Linux and Windows

*** Jim escribió/wrote (5 Dec 2005 17:35:43 -0800):
Quoted text here. Click to load it

Since directories do differ, you must either use relative paths or use
variables. Check $_SERVER['DOCUMENT_ROOT']. Also, dirname(__FILE__) may be

-+ Álvaro G. Vicario - Burgos, Spain
++ es mi sitio para programadores web
+- es mi web de humor libre de cloro

Site Timeline