?>
PHP
手册中描述了大约 50 个用于处理数组的函数。
2.
在 PHP 字符串中加入变量
这个很简单的:
$temp = "hello"
echo "$temp world";
?>
但是需要说明的是,尽管下面的例子没有错误:
$temp = array("one" => 1, "two" => 2);
// 输出:: The first element is 1
echo "The first element is $temp[one].";
?>
但是如果后面那个 echo 语句没有双引号引起来的话,就要报错,因此建议使用花
括号:
$temp = array("one" => 1, "two" => 2);
echo "The first element is .";
?>
3. 采用关联数组存取查询结果
看下面的例子:
$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:tn";