+ 2
PHP Arithmetic Operators
Hi there Can anyone explain the output of the following code? I can't find anything in the manual that refers to +- operators next to each other? <?php $sale = 200; $sale = $sale - + 1; echo $sale; //Output 199 $sale = $sale + - 1; echo $sale; //Output 199 ?>
2 ответов
+ 5
I think it's not +- or -+ operator. It works like this :
s = s + (-1)
or, s = s - 1
s = s - (+1)
or, s = s - 1
Thats why if s = 200
both equation returns
s - 1 = 200 - 1 = 199
+ 3
hope that you are aware of negative number in maths, 200 - +1 means 200 substraction positive 1 that is 199, similarly 200+ -1 means add negative 1 to 200 that will be 199.