PHP Arithmetic Operators | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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 ?>

11th Apr 2017, 10:50 AM
altergothen
altergothen - avatar
2 Answers
+ 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
11th Apr 2017, 11:01 AM
Cyrus Ornob Corraya
Cyrus Ornob Corraya - avatar
+ 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.
11th Apr 2017, 3:51 PM
Nithin
Nithin - avatar