|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 09:00:01 2025 UTC |
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.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.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.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...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.