PHP $ _ SERVER [DOCUMENT_ROOT] problem $ _ SERVER ['document _ root'] value is empty, but there is actual data on the phpinfo () test page, where is the problem with my program? Or configuration problems?
/*
Test Procedure
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 23 Stepping 10, 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 SERVER configuration. Are you sure phpinfo has this value?
Your $ _ SERVER array output ['document _ root'] is obviously empty.
This value is indeed available in phpinfo. It's strange. I don't know if there is any problem in the code.
Settings in httpd. conf
DocumentRoot "D: \ Apache \ htdocs"
_ SERVER ["DOCUMENT_ROOT"] D:/Apache/htdocs
Your $ _ SERVER array output ['document _ root'] is obviously empty.
I want to know why it is empty?
Echo $ _ SERVER ["DOCUMENT_ROOT"];
I personally think it should not be entangled in $ _ SERVER ['document _ root']
This variable does not pass through each server. if it is not allowed to change to another server, an error will be found and the code will be rewritten.
We recommend that you use _ FILE _ or _ DIR __
If you really need to know why, check the information. it is said that the virtual machine has a problem with this variable and there is no environment test.