1. Arithmetic operators: +, -, *, /, %.
2. Increment/decrement operators: such as $a++,$a--,++$a,--$a.
For example:
$a=10;
$b=5;
$c=$a++; //Assign value first, then increment. $c=$a,$a=$a+1
$d=$b--; //Assign value first, then decrement. $d=$b,$b=$a-1
echo '$a='.$a."||".'$c='.$c.'
'; //$a=11,$c=10
echo '$b='.$b."||".'$d='.$d.'
'; / /$b=4,$d=5
?>
$a=10;
$b=5;
$c=++$a; //Increment first, then assign value. $a=$a+1, $c=$a
$d=--$b; //Decrease first, then assign value. $b=$a-1, $d=$b
echo '$a='.$a."||".'$c='.$c.'
'; //$a=11,$c=11
echo '$b='.$b."||".'$d='.$d.'
'; / /$b=4,$d=4
?>
3. Comparison operator: reference document
4. Logical operators:
For example:
$a=10;$b=7;
if($a++>8 || $b++>7){ //$a++>8 is true , $b++>7 will not be executed
echo 'OK!';
}
echo 'a='.$a.'b='.$b; // Output OK, a=11,b=7
Change it
$a=10;$b=7;
if($a++>10 && $b++>7){ //$a++ >8 is false, $b++>7 This will not be executed
echo 'OK!';
}
echo 'a='.$a.'b=' .$b; // a=11,b=7
Details: and && both represent logical AND, what is their difference?
Mainly reflected in the priority
$a=false || true; //&& > = > and ;Compare false || true first, then assign value
$b=false or true; //|| > = > or ;Assign $b=false first and then compare, so the result is false
var_dump($a,$b); //bool(true) bool( false)