<html>
<head>
<meta http-equiv="content-type" content="text/html"; charset="utf-8">
<title>第一个PHP程序(获取服务器信息)</title>
</head>
<body>
<?php
$sysos=$_SERVER["SERVER_SOFTWARE"];
$sysersion= PHP_VERSION;
mysql_connect("localhost","root","root");
$mysqlinfo=mysql_get_server_info();
if(function_exists("gd-info")){
$gd= gd_info();
$gdinfo= $gd[‘GD Version‘];
}else {
$gdinfo="未知";
}
$freetype = $gd["FreeType Support"] ? "支持":"不支持";
$allowurl=ini_get("alllow_url_fopen") ? "支持":"不支持";
$max_ex_time=ini_get("fole_upload") ? ini_get("upload_max_filesize") : "Disable";
$max_ex_time=ini_get("max_exection_time")."秒";
date_default_timezone_set("Etc/GMT-8");
$systemtime=date("Y-m-d H:i:s",time());
echo "<table align=center cellspacing=0 cellpadding=0>";
echo "<caption> <h2>系统信息</h2></caption>";
echo "<tr><td>Web服务器:</td> <td> $sysos</td></tr>";
echo "<tr><td>PHP版本:</td> <td> $sysversion </td></tr>";
echo "<tr><td>MySQL版本:</td> <td> $mysqlinfo</td></tr>";
echo "<tr><td>GD库版本:</td> <td> $gdinfo</td></tr>";
echo "<tr><td>FreeType:</td> <td> $freetype </td></tr>";
echo "<tr><td>远程文件获取:</td> <td> $allowurl</td></tr>";
echo "<tr><td>最大上传限度:</td> <td> $max_upload</td></tr>";
echo "<tr><td>最大执行时间:</td> <td> $max_ex_time</td></tr>";
echo "<tr><td>服务器时间:</td> <td> $systemtime</td></tr>";
echo "</table>";
for($i=1;$i<10;$i++){
for($j=1;$j<$i+1;$j++){
echo $j.‘x‘.$i.‘=‘.$i*$j.‘ ‘;
}
echo ‘<br/>‘;
}
$i=1;
$j=2;
$k=$i+$j;
echo $j+$i;
echo ‘<br>‘;
echo ‘$i+$j‘;
echo ‘<br>‘;
echo "$i+$j";
echo ‘<br>‘;
echo "我是$i";
echo ‘<br>‘;
echo "我是\$j=$j".‘<br>‘;
function add($a,$b){
$k=$a+$b;
return $k;
}
echo add($i,$j).‘<br>‘;
echo add(1,1,1,1,1).‘<br>‘;
function drawTable($width,$height){
echo "<table style=‘color:#fff‘>";
for($i=0;$i<$width;$i++){
if($i%2==0){
echo "<tr style=‘background:red;‘>";
}else{
echo "<tr style=‘background:green;‘>";
}
for($j=$i*$width;$j<($i+1)*$width;$j++){
echo "<td>";
echo $j;
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
}
drawTable(4,4);
?>
</body>
</html>
原文地址:http://12155715.blog.51cto.com/12145715/1865537