LAMP 架构的网站,我以前注重的多是安装/配置方面的,讲述开发的相对较少,因为自己从事开发也少。看了以后,颇有启发,以前开发中遇到的一些问题,迎刃而解。所
1. PHP 中数组的使用
复制代码 代码如下:
$temp[0] = "richmond";
$temp[1] = "tigers";
$temp[2] = "premiers";
for($x=0;$x
echo $temp[$x];
echo " ";
}
?>
复制代码 代码如下:
$temp = array("richmond", "tigers", "premiers");
foreach ($temp as $element)
echo "$element ";
?>
复制代码 代码如下:
$temp = array("club" => "richmond",
"nickname" =>"tigers",
"aim" => "premiers");
foreach ($temp as $key => $value)
echo "$key : $value ";
?>
复制代码 代码如下:
$temp = "hello"
echo "$temp world";
?>
复制代码 代码如下:
$temp = array("one" => 1, "two" => 2);
// 输出:: The first element is 1
echo "The first element is $temp[one].";
?>
复制代码 代码如下:
$temp = array("one" => 1, "two" => 2);
echo "The first element is {$temp["one"]}.";
?>
复制代码 代码如下:
$connection = mysql_connect("localhost", "albert", "shhh");
mysql_select_db("winestore", $connection);
$result = mysql_query("SELECT cust_id, surname,
firstname FROM customer", $connection);
while ($row = mysql_fetch_array($result))
{
echo "ID:\t{$row["cust_id"]}\n";
echo "Surname\t{$row["surname"]}\n";
echo "First name:\t{$row["firstname"]}\n\n";
}
?>
复制代码 代码如下:
for($counter=0; $countermyFunction();
?>
复制代码 代码如下:
error_reporting(E_ALL);
for($counter=0; $countermyFunction();
?>
复制代码 代码如下:
复制代码 代码如下:
// 数据库功能
// 重定向
header("Location: $HTTP_REFERER");
exit;
?>
复制代码 代码如下:
$query = "INSERT INTO customer
SET surname = $surname,
firstname = $firstname";
$connection = mysql_connect("localhost", "fred", "shhh");
mysql_select_db("winestore", $connection);
$result = mysql_query($query, $connection);
?>
BR>"-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd" >
复制代码 代码如下: