$a=1;
$b=2;
echo $a.$b."<br/>";
$a=1;
$b=2;
echo $a+$b."<br/>";
echo '加减号'.($a+$b)."<br/>";
$a=1;
$b=2;
var_dump('求余符号'.$a%$b);
echo '比较运算符'.($a==$b)."<br/>";
- 整数0 为假 非0整数为真
$num=0;
echo '整数0为假';
if($num){
echo 'true'.'<br/>';
}else{
echo 'false'.'<br/>';
}
- 空字符串为假
$str='';
echo '空字符串为假';
if($str){
echo 'true'.'<br/>';
}else{
echo 'false'.'<br/>';
}
- 空字符串的0为假
$strnum='0';
echo '空字符串的0为假';
if($strnum){
echo 'true'.'<br/>';
}else{
echo 'false'.'<br/>';
}
- 空数组为假
$arr=[];
echo '空数组为假';
if($arr){
echo 'true'.'<br/>';
}else{
echo 'false'.'<br/>';
}
- null为假
$null=null;
echo 'null为假';
if($null){
echo 'true'.'<br/>';
}else{
echo 'false'.'<br/>';
}
- 获取一定范围内的随机整数
$shaizi=mt_rand(1,6);
echo $shaizi;