Php Tutorial increment/decrease operator
Only one operation of variables
The increment/decrease operator does not affect Boolean values. Decreasing the NULL value does not work, but the result of increasing the NULL value is 1.
Example name effect
+ + $ A add the value of $ a plus one, and then return $.
$ A ++ returns $ a after adding, and then adds the value of $.
-- Minus $ a before $ a minus one, and then returns $.
$ A -- returns $ a after subtraction, and then drops the value of $ a by one.
<? Php
$ A = 1;
Echo "add before"; // add one to the value of $ a, and then return $
Echo ++ $ a; // Display value 2
$ A = 1;
Echo "add after"; // return $ a, and then add the value of $
Echo $ a ++; // The displayed value is 1.
$ A = 2;
Echo "minus"; // subtract one from $ a, and then return $
Echo -- $ a; // The displayed value is 1.
$ A = 2;
Echo "minus"; // $ Returns $ a, and then drops the value of $ a by one.
Echo $ a --; // Display value 2
?>
<? Php
Echo "$ A = 5;
Echo "shocould be 5:". $ a ++. "<br/> n ";
Echo "shocould be 6:". $ a. "<br/> n ";
Echo "$ A = 5;
Echo "shocould be 6:". ++ $ a. "<br/> n ";
Echo "shocould be 6:". $ a. "<br/> n ";
Echo "$ A = 5;
Echo "shocould be 5:". $ a --. "<br/> n ";
Echo "shocould be 4:". $ a. "<br/> n ";
Echo "$ A = 5;
Echo "shocould be 4:". -- $ a. "<br/> n ";
Echo "shocould be 4:". $ a. "<br/> n ";
?>