获取数组中的元素示例<HTML>
<HEAD>
<TITLE>获取数组中的元素</TITLE>
</HEAD>
<?
$monthName = array(
/*定义$monthName[1]到$monthName[12]*/
1=>"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December",
/*定义$monthName["Jan"]到$monthName["Dec"]*/
"Jan"=>"January", "Feb"=>"February",
"Mar"=>"March", "Apr"=>"April",
"May"=>"May", "Jun"=>"June",
"Jul"=>"July", "Aug"=>"August",
"Sep"=>"September", "Oct"=>"October",
"Nov"=>"November", "Dec"=>"December",
/*定义$monthName["Jan"]到$monthName["Dec"]*/
"January"=>"January", "February"=>"February",
"March"=>"March", "April"=>"April",
"May"=>"May", "June"=>"June",
"July"=>"July", "August"=>"August",
"September"=>"September", "October"=>"October",
"November"=>"November", "December"=>"December"
);
/*打印相关的元素*/
print("Month <B>5</B> is <B>" . $monthName[5]. "</B><BR>\n");
print("Month <B>Aug</B> is <B>" . $monthName["Aug"] . "</B><BR>\n");
print("Month <B>June</B> is <B>" . $monthName["June"] . "</B><BR>\n");
?>
</BODY>
</HTML>
创建一个多维php数组示例 <HTML>
<HEAD>
<TITLE>创建一个多维数组</TITLE>
</HEAD>
<?
$Cities = array( //二维数组array()
"华北地区"=>array(
"北京市",
"天津市",
"石家庄"
),
"西北地区"=>array(
"西安",
"拉萨"
)
);
print("华北地区: ".$Cities["华北地区"][0]); //打印$Cities["华北地区"][0]
?>
</BODY>
</HTML>
PHP 4.0实现表格状打印<HTML>
<HEAD>
<TITLE>实现表格状打印</TITLE>
</HEAD>
<BODY>
<?
/*
** 数据表格化
*/
print("<TABLE bgcolor='ffccoo' BORDER=\"1\">\n"); // 表格开始
for($Row=1; $Row <= 12; $Row ++)
{
print("<TR>\n"); // 开始行
// do each column
for($Column=1; $Column <= 12; $Column ++)
{
print("<TD>");//开始列
print($Row * $Column);//表格元素乘积
print("</TD>");
}
print("</TR>\n"); // 行结束
}
print("</TABLE>\n"); // 表格结束
?>
</BODY>
</HTML>
查看系统的一些变量<HTML>
<HEAD>
<TITLE>查看PHP的环境变量</TITLE>
</HEAD>
<BODY>
<?
print("你正在用文件的名字为: ");
print(__FILE__);
print(" <BR>\n");
print("<hr>");
print("你的操作系统为: ");
print(PHP_OS);
print("<hr>");
print("你的php的版本为: ");
print(PHP_VERSION)
?>
</BODY>
</HTML>
延伸阅读:6道php面试题,看你会几个据说是一家大公司的PHP面试题 php程序员面试题PHP面试题汇总据说是yahoo的php面试题(E文的哦)腾讯PHP工程师笔试题从 PHP 一道测试题说起PHP高级工程师的面试题