PHP arithmetic operators
operator name Example results+ Addition$x+$y $xAnd$ysum-Subtraction$x-$y $xAnd$ythe differential* Multiplication$x*$y $xAnd$yProduct of/Division$x/$y $xAnd$ythe quotient% modulus$x%$y $xExcept$yThe remainder
The following example shows the different results using different arithmetic operators:
<?PHP$x=10; $y=6;Echo($x+$y);//OutputEcho($x-$y);//Output 4Echo($x*$y);//OutputEcho($x/$y);//Output 1.6666666666667Echo($x%$y);//Output 4?>
---------------------I'm a delimiter-----------------------------------
PHP Assignment operators:
The PHP assignment operator is used to write values to variables. The base assignment operator in PHP is "=". This means that the right-hand assignment expression sets the value for the left-hand operand.
assignment equals = y x = y + = y x = x + y = y x = x- y *= Y x = x * y /= y x = x/ y %= y x = x% y modulus
The following example shows the different results using different assignment operators:
<?PHP$x=10; Echo $x;//Output Ten$y=20; $y+ = 100;Echo $y;//Output$z=50;$z-= 25;Echo $z;//Output$i=5;$i*= 6;Echo $i;//Output$j=10;$j/= 5;Echo $j;//Output 2$k=15;$k%= 4;Echo $k;//Output 3?>
-------------------------wo shi fen ge fu-------------------------------
PHP string operators:
operator Name example results . Threaded $txt 1$txt 2$txt 1 . "World!" $txt 2 contains "Hello world!". = string Assignment $txt 1$txt 1 . = "world!" $txt 1 contains "Hello world!"
The following example shows the result of using the string operator:
<? PHP $a = "Hello"; $b $a . "World!" ; Echo $b // Output Hello world! $x= "Hello"; $x . = "world!" ; Echo $x // output Hello world!? >
------------delimiter-----------------------
PHP increment/Decrement operators:
operator name description + +$x before increment $x$x$x+ + after increment $x $x plus one increment --$x before descending $x$x$x-- after descending $x $x decrease by one decrease
The following example shows the different results using different increment/decrement operators:
<?PHP$x=10; Echo++$x;//output one by one$y=10; Echo $y++;//Output Ten$z=5;Echo--$z;//Output 4$i=5;Echo $i--;//Output 5?>
------------Fengefu--------------------
PHP comparison operators:
A PHP comparison operator is used to compare two values (numbers or strings):
operator name Example results= = equals$x==$yIf$xEquals$y, The returntrue. = = = Congruent (exact same)$x===$yIf$xEquals$y, and they are of the same type, returntrue. ! = does not equal$x!=$yIf$xNot equal to$y, The returntrue. <> Not equal to$x<>$yIf$xNot equal to$y, The returntrue. !== not congruent (completely different)$x!==$yIf$xNot equal to$y, and they are not of the same type, returntrue. > Greater than$x>$yIf$xGreater than$y, The returntrue. < greater than$x<$yIf$xLess than$y, The returntrue. >= greater than or equal to$x>=$yIf$xGreater than or equal to$y, The returntrue. <= less than or equal to$x<=$yIf$xLess than or equal to$y, The returntrue。
The following example shows the different results of using some comparison operators:
<?PHP$x=100; $y= "100";Var_dump($x==$y);//Note that this is var_dump not echo Oh,Echo"<br>";Var_dump($x===$y);Echo"<br>";Var_dump($x!=$y);Echo"<br>";Var_dump($x!==$y);Echo"<br>";$a=50;$b=90;Var_dump($a>$b);Echo"<br>";Var_dump($a<$b); ?>
-----------------separated-character----------------------
PHP logical operators:
operator name example results and and$xand$yIf$xAnd$yAre fortrue, The returntrue. OR or$xOr$yIf$xAnd$yThere is at least onetrue, The returntrue. Xor different or$xXor$yIf$xAnd$yThere is only onetrue, The returntrue. && and$x&&$yIf$xAnd$yAre fortrue, The returntrue. || Or$x||$yIf$xAnd$yThere is at least onetrue, The returntrue. ! Non -!$xIf$xNot fortrue, The returntrue。
---------------Fen-ge-fu-----------------------------
PHP Array Operators
The PHP array operator is used to compare arrays:
operator name Example results+ Union$x+$y $xAnd$yUnion (but does not overwrite duplicate keys)= = Equal$x==$yIf$xAnd$yHas the same key/value pair, it returnstrue. = = = Congruent$x===$yIf$xAnd$yHave the same key/value pairs, and the same type is the same in the same order, returnstrue. ! = is not equal$x!=$yIf$xNot equal to$y, The returntrue. <> Not Equal$x<>$yIf$xNot equal to$y, The returntrue. !== not congruent$x!==$yIf$xAnd$yis completely different, it returnstrue。
The following example shows the different results using different array operators:
<?PHP$x=Array("A" and "Red", "b" = "green")); $y=Array("c" = "Blue", "d" = "Yellow"); $z=$x+$y;//$x union with the $yVar_dump($z);Var_dump($x==$y);Var_dump($x===$y);Var_dump($x!=$y);Var_dump($x<>$y);Var_dump($x!==$y);?>