PHP $_server[' document_root ' issues

Source: Internet
Author: User
Tags phpinfo
$_server[' document_root ' value is empty, but there is actual data on the phpinfo () test page, which is the problem with my program? Or a problem with the configuration?
/*
Test program
Call base_info.php
*/
Print_r ($_server);
$SYSTEM _root_path = $_server[' document_root ');
#echo $_server[' Document_root ']. " \ n ";
echo $SYSTEM _root_path;
/*
Include ("$SYSTEM _root_path\lib\base_info.php");

$class = new Base_info ();

$S _info = $class->system_info ();
foreach ($key as $value) {
echo "$key ======== $value". \ n ";
}
*/

$_server Array Output
[AllUsersProfile] = C:\ProgramData
[Ant_home] = D:\hadoop\apache-ant-1.9.2
[APPDATA] = C:\Users\yjn\AppData\Roaming
[CLASSPATH] =,;D: \hadoop\java/lib/dt.jar;d:\hadoop\java/lib/tools.jar
[CommonProgramFiles] = C:\Program files (x86) \common files
[CommonProgramFiles (x86)] = C:\Program files (x86) \common files
[CommonProgramW6432] = C:\Program Files\Common Files
[COMPUTERNAME] = yjn-pc
[ComSpec] = C:\Windows\system32\cmd.exe
[Fp_no_host_check] = NO
[Homedrive] = C:
[HomePath] = \users\yjn
[Java_home] = D:\hadoop\Java
[LocalAppData] = C:\Users\yjn\AppData\Local
[LogonServer] = \\YJN-PC
[Number_of_processors] = 2
[OS] = Windows_NT
[Path] = C:\Perl64\site\bin; C:\Perl64\bin; C:\Windows\system32; C:\Windows;
Ndows\system32\wbem; C:\Windows\System32\WindowsPowerShell\v1.0\;D: \hadoop\j
In;d:\hadoop\java/jre/bin;d:\hadoop\apache-ant-1.9.2\bin;d:\php5;d:\php5\ex
[Pathext] =. COM;. EXE;. BAT;. CMD;. VBS;. VBE;. JS;. JSE;. WSF;. WSH;. MSC
[Processor_architecture] = x86
[processor_architew6432] = AMD64
[Processor_identifier] = Intel64 Family 6 Model stepping, Genuinein

[Processor_level] = 6
[Processor_revision] = 170a
[ProgramData] = C:\ProgramData
[ProgramFiles] = C:\Program Files (x86)
[ProgramFiles (x86)] = C:\Program Files (x86)
[ProgramW6432] = C:\Program Files
[PROMPT] = $P $g
[Psmodulepath] = C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
[Public] = C:\Users\Public
[SessionName] = Console
[SystemDrive] = C:
[SystemRoot] = C:\Windows
[TEMP] = C:\Users\yjn\AppData\Local\Temp
[TMP] = C:\Users\yjn\AppData\Local\Temp
[UserDomain] = yjn-pc
[USERNAME] = Yjn
[UserProfile] = C:\Users\yjn
[windir] = C:\Windows
[Windows_tracing_flags] = 3
[Windows_tracing_logfile] = C:\BVTBin\Tests\installpackage\csilogfile.log
[Php_self] = test.php
[Script_name] = test.php
[Script_filename] = test.php
[Path_translated] = test.php
[Document_root] =
[Request_time] = 1381282125
[argv] = = Array
(
[0] = test.php
)

[ARGC] = 1




Reply to discussion (solution)

$_server[' Document_root '] needs to be specified in the server configuration, are you sure phpinfo has this value?

You $_server the array output [' document_root '] is obviously empty.

It is true that this value can be reached in phpinfo. It's strange that I don't know if there's a problem in the code
Settings in the httpd.conf
DocumentRoot "D:\Apache\htdocs"


_server["Document_root"] D:/apache/htdocs

You $_server the array output [' document_root '] is obviously empty.
I just want to know why it's empty?

echo $_server["Document_root"];

Personally feel that should not be entangled in $_server[' document_root ']
This variable does not pass through the server, it is not necessary to change a server to check the wrong and rewrite the code
Recommended with __file__ or __dir__

If you really need to know why, go to check the information, reportedly virtual machine with this variable is also a problem, no environmental measurement

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.