php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14797 include (_path) in Apache SAPI and CGI on Win98SE does not work
Submitted: 2002-01-02 08:30 UTC Modified: 2002-03-13 20:50 UTC
Votes:5
Avg. Score:4.2 ± 1.2
Reproduced:4 of 5 (80.0%)
Same Version:2 (50.0%)
Same OS:1 (25.0%)
From: m at rtin-burger dot de Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.1.0 OS: Windows 98 SE
Private report: No CVE-ID: None
 [2002-01-02 08:30 UTC] m at rtin-burger dot de
Hello,

I can't run PHP Version 4.1.0 under Windows 95/98 4.10, there are
massive problems when I try to include a file:

Server API CGI
--------------

- It's possible to set the include-path in php.ini.

- Scripts without any include statement work well.

- include statements with a relative path work.

- include statements with an absolute path do not work, there is the
  following error:
  Failed opening '/foo/test.php' for inclusion

Server API Apache
-----------------

- It is not possible to set the include-path in php.ini to an other
  value than "". If I do, there will be everytime the same error:
  Failed opening 'foo/index.php' for inclusion (include_path='.;/foo')
  in Unknown on line 0

- If I set the include-path in php.ini to "" and in a script with
  ini_set("include_path", $new_inc_path) to the desired path, then php
  shows the same behaviour like "Server API CGI" - only relative paths
  work.

I think this could be the bug #11612 or #14563, bit I don't use Win2k,
I'm using Win 98 SE.

Martin

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-02 08:58 UTC] m at rtin-burger dot de
With PHP Version 4.0.5RC1 an inlude-path set to ";.;./;" it works with SAPI, but with 4.0.6 and newer it's the same like 4.1.0

Martin
 [2002-01-10 06:26 UTC] m at rtin-burger dot de
Hello,

whenever  I  add  the  drive  letter  (d:)  to the DocumentRoot of the
VirtualHost,  there  is  the same error as with PHP running as "Server
API CGI":

- It's possible to set the include-path in php.ini.

- Scripts without any include statement work well.

- include statements with a relative path work.

- include statements with an absolute path do not work, there is the
  following error:
  Failed opening '/foo/test.php' for inclusion

However,  it is now possible to start PHP with include-path in php.ini
set to a non-empty value.

But for me, it's very important to use include with an absolute path.

I  tried to put the file "test.php" into the folder "foo" on drive c:,
but  this  doesn't work properly too. I thought PHP is looking for the
file  on  the  wrong  disk,  but  this  seems to be not the underlying
problem.

Regards,

Martin

 [2002-01-10 07:36 UTC] m at rtin-burger dot de
Hello,

when   I   add  the  drive  letter  to  the  include  statement  (e.g.
'd:/foo/test.php'), then the inclusion works properly.

But then all scripts only run on a window machine or we have to change
every   script   before   uploading   it   to  our  "real"  webserver,
respectively.

Regards,

Martin

 [2002-01-15 23:21 UTC] garth at utmail dot to
The Solution:
-------------

You need to add the drive letter as follows

DocumentRoot "D:\apache/htdocs/"
                ^
                | emphasis on the "\"

then relative include_path statements should work.

I still think this is a bug, because apache runs fine
with DocumentRoot "/apache/htdocs/", it's only PHP that
has problems when include_path is set.
 [2002-01-15 23:25 UTC] garth at utmail dot to
Oh yeah, the other reason I think it's a bug is because 
the behaviour is not consistant between the CGI version 
and the SAPI version of the same build.

If it has to be inconsistant it should be documented.
(proably a blurb on top of include_path in php.ini would
be the best place for it, since people will find that
include_path causes the problem when their doc_root
is set wrong)
 [2002-01-17 10:02 UTC] m at rtin-burger dot de
Hello,

I tried:

DocumentRoot "d:/foo/htdocs"

DocumentRoot "d:/foo/htdocs/"

DocumentRoot "d:\foo/htdocs"

DocumentRoot "d:\foo/htdocs/"

I used 'php.ini-dist' with include_path set to ".".

Nevertheless,  I can't include files with an absolute path. Statements
with a relative path work properly.

Regards,

Martin

 [2002-01-17 10:19 UTC] mboeren@php.net
I use NT, but that doesn't really matter. What works for me is the following:

If in httpd.conf, the DocumentRoot is d:/foo/htdocs, then
in php.ini, I set include_path to d:/foo/htdocs as well.

In every script that uses include, specify the relative path from d:/foo/htdocs (never from the current file!), _without_ a leading /, e.g. if your include file is d:/foo/htdocs/inc/bla.p, then use
include("inc/bla.p");

You could combine this with tricks like defining a constant ABS_INCL_PATH, setting this to d:/foo/htdocs and then using
include(ABS_INCL_PATH."/inc/bla.p");

This way you can also create more constants, like THIS_PROJECT_ABS_INCL_PATH and GENERAL_TOOLBOX_ABS_INCL_PATH.

Switching to a *nix environment is just a matter of redefining your constants.

Hope this helps, Marc.
 [2002-01-17 10:35 UTC] m at rtin-burger dot de
Yes,  but  I  do not want to edit anything. I want to upload the files
and then it has to work.

Perhaps you can use something like this:

if (strpos($SERVER_SOFTWARE, "Win")) {
    echo "<font color=\"#FF0000\">WINDOWS</font>";
} else {
    echo "<font color=\"#008000\">Uhh, good...</font>";
}

But it's only a dirty workaround.
 [2002-01-17 10:56 UTC] m at rtin-burger dot de
OK, I think I has to use this workaround:

if (strpos($SERVER_SOFTWARE, "Win")) { // Windows - Is there a better way to detect this?
    $NB_INCLUDE_PATH_PREFIX = substr($DOCUMENT_ROOT, 0, 2); // The drive letter - Is there a better way to detect this?
} else { // NOT Windows
    $NB_INCLUDE_PATH_PREFIX = "";
}

include ($NB_INCLUDE_PATH_PREFIX . "/foo/test.php");

But I'm not really happy...
 [2002-01-17 11:11 UTC] mboeren@php.net
How about 

include(getenv("DRIVELETTER")."/foo/test.php");

and setting this environment variable locally (chances are it isn't set on the real webserver).

Cheerio, Marc.
 [2002-01-24 17:48 UTC] james at stealthnet dot co dot uk
We're getting hit by this too. Funny how because the local dev box is windows xp we can't use include_path for a unix main server! :(.

Anyway, I tried the idea of using C:\apache/htdocs as the DocumentRoot, and Apache stopped reading .htaccess files completely, rendering the workaround useless. This is a major issue for us, I'm having to scream for a local unix dev box...
 [2002-01-30 12:50 UTC] garth at utmail dot to
Martin, 

Just checking that you're restarting Apache after each 
edit to PHP.ini...  You don't have to restart in CGI mode
for changes to happen, but SAPI needs it (since PHP
is loaded into Apache's memory space).

-Garth
 [2002-01-30 12:55 UTC] m at rtin-burger dot de
Hello,

D:\127\Apache\Apache.exe  -d "d:\127\apache" -k shutdown

D:\127\Apache\Apache.exe -w -f "D:\127\Apache\conf\httpd.conf" -d "D:\127\Apache\"

Martin
 [2002-02-04 16:45 UTC] phpclub at unet dot ru
I found  solution %)
php_value include_path "/.;C:\var\www;"
Add in include_patch /.
All working! 
Tested in php4.0.4rc1,4.0.6,4.1.1
 [2002-03-13 20:50 UTC] sniper@php.net
This is fixed in CVS. Fix will be in PHP 4.2.0.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Aug 27 23:01:27 2024 UTC