循环控制
<?php
$arr = [3=>'a',1,3,2,5];
var_dump($arr);
/*从3开始存
array (size=5)
3 => string 'a' (length=1)
4 => int 1
5 => int 2
6 => int 3
7 => int 6
*/
//关联数组,类似字典
$arr1 = [
'java' => [
3=>'a',1,3,2,5
],
'php' => 16800,
'python' => 21800,
'go' => '暂未开通'
];
var_dump($arr1);
//echo $arr1['java']; 报错,echo只能用来输出字符串
var_dump($arr1['java']);
foreach循环取值
<?php
$arr1 = [
'java' => [
3=>'a',1,3,2,5
],
'php' => 16800,
'python' => 21800,
'go' => '暂未开通'
];
foreach ($arr as $key => $value) {
echo $key . '----' .$value;
}
while(list())取值
<?php
$arr = [1,2,3,5,4,6];
while(list($key,$value) = each($arr)){
echo $key.'***'.$value.'<br />';
}
错误处理
display_error 改成off可以屏蔽错误
log日志: error.log查找错误日志存放位置