//设置php页面编码
header("Content-Type:text/html; charset=gb2312");
//数组的使用
<?php
$arr = array("123","321", "34435");
echo $arr[1];
echo "<br>";
$arr1 = array("key1" => "456","key2" => "89",4 => "45");
echo $arr1[key2];
echo "<br>";
$arr2 = array(23,34,1,2,54);
sort($arr2);//自动从小到大进行排列
print_r($arr2);
echo "<br>";
print_r($arr1);
?>
//使用list提取数组
<?php
$array = array("PHP", "MySql", "Apache");
list($php, $mysql, $apache) = $array;
echo "$php+$mysql+$apache<br>";
function test()
{
$value[] = "php";
$value[] = "mysql";
$value[] = "apache";
return $value;
}
list($php,$mysql,$apache) = test();
echo "$php*$mysql*$apache";
?>
//引用赋值,与全局,局部变量
<?php
$str1 = "eduask";
$str2 = "shanghai";
echo $str2."<br>";
$str2 = &$str1;//引用赋值
echo $str2."<br>";
$str1 = "eduask beijing";
echo $str2."<br>";
$str2 = "shanghai eduask";
echo $str1."<br>";
function test()
{
//$str1 = "In the function str1"; //局部变量
echo $str1."<br>";
}
test();
echo $str1."<br>";//全局变量
?>
//变量中,单引号和双引号的区别(不解释,解释)
<?php
$str="123";
echo '$str';
echo "$str";
?>
//isset(变量),判断是否设置了值
if(isset($name))
//加载(包含)外部php文件
include_once("外部文件");