Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
//算术运算符
$num1 = 10;
$num2 = 20;
// echo $num1 + $num2; //输出30
// echo $num1 - $num2; //输出-10
// echo $num1 * $num2; //输出200
// echo $num1 / $num2; //输出0.5
echo $num1 % $num2; //输出10
echo '<hr/>';
// 字符串连接符
$str1 = 'hello';
$str2 = 'world';
echo $str1 . ' ' . $str2; //输出hello world
echo '<hr/>';
//赋值运算符
$n = 5;
$m = 6;
// echo $n += $m; //输出11
// echo $n -= $m; //输出-1
// echo $n *= $m; //输出30
// echo $n /= $m; //输出0.83333333333333
// echo $n .= $m; //输出56 ,最后的56是string类型
// var_dump($n .= $m); //string(2) "56"
// echo $n++; //输出5 ,先输出5,再将n+1
// echo ++$n; //输出6 ,先计算n+1,再将结果6赋值给n,最后再输出新的n
// echo $n--; //输出5
echo --$n; //输出4
echo '<hr/>';
//字符串查找
$string = 'abcdefg';
$search = 'cDe';
// echo strpos($string, $search); //输出空 ,查找时大小写敏感
// echo stripos($string, $search); //输出2 ,查找时忽略大小写
// echo strstr($string, $search); //输出空 ,查找时大小写敏感
echo stristr($string, $search); //输出cdefg ,查找时忽略大小写
echo '<hr/>';
$string = ' ';
$replace = ' ';
$search = chr(32);
echo 'aaa' . str_replace($search, $replace, $string) . 'bbb'; //输出aaa bbb
// str_ireplace($search, $replace, $string) //查找时忽略大小写
//字符串截取和替换
echo '<hr/>';
$str = 'hello world';
// echo substr($str,6); //输出world
echo substr_replace($str,'aaa',6); //输出hello aaa