<html>
<head>
<meta content="cntent-type" content="text/html;charset=gb2312">
<title>第一个PHP程序<?php echo"PHP语言标记使用"."<br>" ?></title>
<style type="text/css">
body{
margin:0px;
background:#ccc;
}
</style>
</head>
<body <?php echo'bgcolor="red"' ?>>
<script type="text/javascript">
alert("客户端的时间"+(new Date()));
</script>
<?php
echo"服务器时间".date("Y-m-d H:i:s")."<br>";
?>
<?php
$sysos={1}SERVER["SERVER_SOFTWARE"];
$sysversion=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("allow_url_fopen")?"支持":"不支持";
$max_upload=ini_get("file_uploads")?"支持":"不支持";
$max_ex_time=ini_get("max_execution_time")?ini_get("upload_max_filesize"):"Disable";
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>Free Type: </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>";
?>
<?php
$expression=4;
if($expression){
?>
<p align="<?php echo'center'?>">this is true</p>
<?php }else{
?>
<p>this is false</p>
<?php
}
?>
<?php echo"1.这个标记是标准PHP语言标记。"."<br>"?>
<script language="php">
echo"2.这个标记是脚本风格,是最长的标记<br>";
</script>
<? echo "3.这是最短的标记风格"."<br>" ?>
<?=$expression ?>这也是一种简单方式,等价于<br><? echo $expression ?>
<% echo"这个标记类似于ASP标签的写法<br>" %>
<%=$expression %>这也是一种简单方式,等价于<% echo $expression %>
<?php
$var='';
if(empty($var)){
echo"<br>".'$var is either 0 or not set at all';
}
if(!isset($var)){
echo'$var is not set at all';
}
unset($var);
if(isset($var)){
print"this var is set set so i will print";
}
$hi="hello";
$hi="world";
echo"<br>$hi";
echo"<br>${$hi}";
echo"<br>$hi$hello";
echo"<br>$hi${$hi}";
$foo='bob';
$bar=&$foo;
$bar="my name is tom";
echo "<br>".$bar;
echo "<br>".$foo;
$foo="your name is bob";
echo "<br>".$bar;
echo "<br>".$foo;
$bool=true;
$str="string";
$int=123;
var_dump($bool);
var_dump($str);
var_dump($int);
var_dump((bool)"false");
$num=123456333999;
$max=50000*$num;
$flo=1.2e3;
var_dump($flo);
var_dump($num);
var_dump($max);
echo 'this is g \'simple\' string'."<br>";
$arr=array("fo1"=>"bar",12=>true);
print_r($arr);
echo "<br>".$arr["fo1"];
echo "<br>".$arr[12]."<br>";
class person{
var $name="jack";
function say(){
echo "\tdong method";
}
}
$p=new person;
echo $p->name;
$p->say();
?>
</body>
</html>