Blogger Information
Blog 16
fans 0
comment 0
visits 10751
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php变量作用域+条件语句-2018年8月23日
兔子的博客
Original
763 people have browsed it

数据类型判断检测

实例

<?php
	$a='123';
	$b=123;
	$c=12.3;
	$d=true;
	$age=[10,12,13,14,15,16,17,18];
	$num = count($age); //数组内元素数量
	echo gettype($a).'<br>';//变量检测
	echo gettype($b).'<br>';
	echo gettype($c).'<br>';
	echo gettype($d).'<br>';
	echo settype($c,'integer');
	echo gettype($c).'<br>';//设置变量
	//判断数字大小分类
	//注意判断条件
	for($i=0;$i<$num;$i++){
		//echo $age[$i];
		if($age[$i]<13){
			echo $age[$i].'<br>';
		}else if (13<=$age[$i]&&$age[$i]<17) {
			echo $age[$i].'<br>';
		}else if($age[$i]>=17){
			echo $age[$i].'<br>';
		}
	}
?>

运行实例 »


点击 "运行实例" 按钮查看在线实例

for循环if判断语句案例

VAOCB83VNP[59B11R~}LUGX.jpg

Correction status:qualified

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!