server变量 小练习

73 阅读1分钟

<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 实例</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="cdn.bootcss.com/bootstrap/4…">
<script src="cdn.bootcss.com/jquery/3.2.…>
<script src="cdn.bootcss.com/popper.js/1…>
<script src="cdn.bootcss.com/bootstrap/4…>
</head>
<body>


<div class="container">
<h2>server元素</h2>          
<table class="table table-bordered">
<thead>
<tr>
<th>元素名称</th>
<th>使用形式</th>
<th>结果</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<?php 
$serverItem['REMOTE_ADDR']="当前用户 IP";
$serverItem['REMOTE_PORT']="端口。";
$serverItem['PHP_SELF']="正在执行脚本的文件名";
$serverItem['GATEWAY_INTERFACE']="CGI 规范的版本";
$serverItem['SERVER_PROTOCOL']="请求页面时通信协议的名称和版本 ";
$serverItem['HTTP_REFERER']="链接到当前页面的前一页面的 URL 地址。 ";


$a=<<<EOF
\\_SERVER\['\ EOF;\ \b=<<<EOF
']
EOF;
foreach ($_SERVER as $skey => $svalue) {


foreach ($serverItem as $ikey => $ivalue) {


if($ikey==$skey){


echo "<tr>";
echo "<td>".$ikey."</td>";
echo "<td>".$a.$ikey.$b."</td>";
echo "<td>".$svalue."</td>";
echo "<td>".$ivalue."</td>";
echo "</tr>";
}
}


}
?>
</tbody>
</table>
</div>
</body>
</html>