English 中文(简体)
PHP-IIS
原标题:DOCUMENT ROOT variable on PHP-IIS

<代码>_SERVER[“DOCUMENT_ROOT”]在管理PHP时有变量? 较早 我认为,这一变量是阿帕奇特的,对国际空间法研究所来说,你必须加以仿效,操纵SCRIPT_FILENAME的变数,但我现在看到这一变数出现在我所安装的IPS上。 能否安全地假设,这种变量将永远存在于国际交易日志中。

最佳回答

无论是在综合调查中,是否总是能够找到根基? 页: 1

国际职工会不总是提供“服务”。 它必须放在编织档案中......

如果将其配置在你的服务器上,你可以使用。 确实,你的书面文件没有变化,否则你就会打破你的文字。

问题回答

IIS 一直没有固定收入。 DOCUMENT_ROOT

你们如何把它放在一个配置档案中,因此,你的其他代码像阿帕奇服务器那样发挥作用?

产出_SERVER,根据您可能使用的信息,了解:

echo "<br>_SERVER:<br><pre>";
print_r($_SERVER);
echo "</pre><br><br>_ENV:<br><pre>";
print_r($_ENV);
echo "</pre><br><br>";

在该案中,确定了SCRIPT_FILENAME和SCRIPT_NAME。

修改以下法典,以利用赋予的获得指定信息库的内容 ROOT:

if (!isset($_SERVER[ DOCUMENT_ROOT ]) || $_SERVER[ DOCUMENT_ROOT ] ===   ) {
    $_SERVER[ DOCUMENT_ROOT ] = substr($_SERVER[ SCRIPT_FILENAME ], 0, -strlen($_SERVER[ SCRIPT_NAME ]));
    putenv( DOCUMENT_ROOT= .$_SERVER[ DOCUMENT_ROOT ]);
}

现在你可以使用_SERVER[DOCUMENT_ROOT]美元。

$docroot = getenv("DOCUMENT_ROOT"); 
include_once "$docroot/folder/yourfile.php"; 

我通过简单地提及我的网络根基并把它作为我自己的变量之一来解决。

<?php
echo getcwd();
chdir( / );
echo getcwd();
chdir( /example-web-server );
echo getcwd();
?>

The following code gets the current working directory of PHP, which will be the directory containing the file you re running this on. chdir( / ) goes to the root of wherever PHP can operate, in my case C:. My example web server s web root is at C:example-web-server, so you can reference it in PHP like this: /example-web-server.

一旦你走到PHP的道路上,你就可以把它当作一个变数,称之为PHP。 页: 1 estingindex.php:

<?php
$webroot = "/example-web-server";
include("{$webroot}/testing/index.php");
?>

我知道这是老的,但我只能是需要解决这一问题的唯一办法。

这是我在指数上所做的事:

if(!isset($_SERVER["DOCUMENT_ROOT"]))
{
    $_SERVER["DOCUMENT_ROOT"]=getcwd();
}




相关问题
Session Management with Windows Authentication

In an ASP.NET web app, using Integrated Windows Authentication, is the session tied to the windows identity? In other words, if I login (using IWA) to the app, and the app stores some "stuff" in my ...

Using Elmah with Cassini

Does anyone know if I can use Elmah with Visual Studio build-in web server(aka Cassini)? I get it working easily on IIS, but using same configuration, it doesn t work with Cassini. When I requested ...

Setting hostname in IIS, include www?

I want to set the hostname for a website I m adding in IIS 7, however do I include the www in the hostname or not? because I want both www.mysite.com and mysite.com both to point to mysite on the ...

inetpub versus any other folder

I ve run websites out of inetpub, as well as from folders just residing on the C: drive. I wonder, are there any definitive advantages to running websites out of inetputwwwroot?

IIS 6.0 hangs when serving a web-service

I am having issues with one of our web-services. It works fine on my development machine (win XP) whether I host it as a separate application or using cassini from Visual studio. Once I deploy on the ...

热门标签