"a--" means quoting first and then decrementing. First use the current value of a in the expression where a is located, and then decrement a by 1; "--a" means decrementing first and then quoting, letting a First subtract 1, and then use the new value of a in the expression where a is.
The difference between a-- and --a is:
a-- is quoted first Then reduce, first use the current value of a in the expression where a is located, and then decrement a by 1
--a is first reduced and then referenced, decrement a by 1 first, and then Use the new value of a in the expression where a is located
They actually all mean a=a-1, but the order of execution is different when running in the program.
The difference between a and --a:
1. Different operation results
1. a: The operation result is the result of the expression a plus One person.
2. --a: The operation result is the result of expression a minus one digit.
2. Different operation processes
1. a: During the operation process, the a expression is executed first, and then the auto-increment operation is executed.
2. --a: During the operation, the auto-decrement operation is performed first, and then the a expression is run.
3. Different memory operations
1. a: Run a in the memory first, and then add 1 to the register.
2. --a: The register in the memory is subtracted by 1 first, and then the a expression is executed.
For more related knowledge, please visit PHP Chinese website! !
The above is the detailed content of What is the difference between a-- and --a?. For more information, please follow other related articles on the PHP Chinese website!