includes on Linux and Windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim

    #1

    includes on Linux and Windows

    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\inc ludes\" and under this directory I have the
    directories "home\xyz\inclu des". 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

  • Alvaro G. Vicario

    #2
    Re: includes on Linux and Windows

    *** Jim escribió/wrote (5 Dec 2005 17:35:43 -0800):[color=blue]
    > Is there a way to issue an include that will work on both Linux and XP
    > under the more recent versions of PHP?[/color]

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

    --
    -+ Álvaro G. Vicario - Burgos, Spain
    ++ http://bits.demogracia.com es mi sitio para programadores web
    +- http://www.demogracia.com es mi web de humor libre de cloro
    --

    Comment

    Working...