Blogger Information
Blog 13
fans 0
comment 0
visits 11017
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
while循环、for循环、数组、数组循环
linuxup的博客
Original
1172 people have browsed it
<?php
header("Content-Type: text/html;charset=utf-8");

// $arr = array(1,"李全权","男",18);
$lqq = array(
	"id"=>1,
	"姓名" =>"李全权",
	"性别"=>"男",
	"年龄"=>18);

$arr = array(
array(
	"id"=>1,
	"姓名" =>"李全权",
	"性别"=>"男",
	"年龄"=>18),
array(2,"李全权","男",18)
);

print_r($arr);//打印数组的方法。
echo count($arr);
echo "<hr>";

$str = "字符串";
$int = 123;
$f = 12.2;
$bl = true;

var_dump($str);   //能够输出数据类型和值(长度);

//用foreach循环位数组
foreach ($arr as $key => $value) {
	echo $key."=>".$value."<br>";
	foreach ($arr[$key] as $k => $v) {
		echo $k."=>".$v."<br>";
	}
}

//$i第一个参数是将变量$i初始化,;第二参数是条件语句,;第三参数是计数器。
for ($i=0; $i < 10 ; $i++) { 
	# code...
	echo "我循环了".$i."次<hr>";
}

$a =20;
if($a <20){    //判断语句  还有else if ()
	echo "low";
}else{
	echo "bangbang";
}

$a = 1
// while ( $a <= 10) {   //条件为真的时候才循环代码块 $a 为计数器, 必须要。不然会死循环
// 	# code...
// 	echo "我循环了".$a."次<hr>";
// 	$a++;
// }

do {								//先执行一次代码块,再进行条件判断,为的假话跳出循环,为真继续循环。
	# code...
	echo "我循环了".$a."次<hr>";
	$a++;
}while($a <= 10)


?>


<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title><?php echo "这是我的第一个php页面"?></title>
</head>
<body>

</body>
</html>

总结

对 php的基本语法,数据类型、初步认识。以及循环的使用方法。

Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!