Why does the PHP parser understand "$x++-++$x", but fail on "$x+++++$x"?

Viewed 1591

I have an engine that does some mathematical and logical operations by taking formulas, operands and operators from a file. All the operations are executed in an eval scope and the final result is saved in another file.

These files are often transferred through a network, so I am trying to minimize them by stripping all the spaces before and after operations. As far as I know there are no strict rules about that matter, however I stumbled upon this behavior:

$x = 1;
$result = $x++-++$x; // works
$result = $x+++++$x; // fails
$result = $x++ + ++$x; // works again
  1. Why is PHP confused by the "+++++" syntax, but accepts "++-++"? How is "plus" better than "minus"?

  2. Is there a list anywhere of operators that are sensitive about spaces?

3 Answers
Related