<?PHP
//遍歷$_ENV變數
echo '<table border="0" width="800" align="center">';
echo '<caption>$_ENV數組</caption>';
$i=0;
foreach($_ENV as $key=>$val){
if($i%2==0){
$bgcolor="red";
}
else{
$bgcolor="blue";
}
echo '<tr bgcolor=".$bgcolor.">';
echo '<td>'.$key.'</td><td>'.$val.'</td>';
echo '</ tr>';
$i++;
}
?>
運行結果:
ALLUSERSPROFILE | C:\Documents and Settings\All Users |
CommonProgramFiles | C:\Program Files\Common Files |
COMPUTERNAME | WANGJIANLONG |
ComSpec | C:\WINDOWS\system32\cmd.exe |
FP_NO_HOST_CHECK | NO |
NUMBER_OF_PROCESSORS | 2 |
OS | Windows_NT |
Path | C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\WBEM;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs |
PATHEXT | .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH |
PROCESSOR_ARCHITECTURE | x86 |
PROCESSOR_IDENTIFIER | x86 Family 6 Model 14 Stepping 8, GenuineIntel |
PROCESSOR_LEVEL | 6 |
PROCESSOR_REVISION | 0e08 |
ProgramFiles | C:\Program Files |
SystemDrive | C: |
SystemRoot | C:\WINDOWS |
TEMP | C:\WINDOWS\TEMP |
TMP | C:\WINDOWS\TEMP |
USERPROFILE | C:\Documents and Settings\LocalService |
windir | C:\WINDOWS |
AP_PARENT_PID | 836 |