55

Just found out these really wierd & pretty useless operators in PHP:

This is called a spaceship operator that simply adds $x and $y but with more style:

$x -=-  $y;

This is an x-fighter. It just adds 5 to $x:

$x = $x +-0-+ 5;

There are several more like these in the documentation.

Comments
  • 10
    and the pain is the interviewer expect you to know this. Otherwise, according to him, you can't build his site.
  • 12
  • 13
    I thought the spaceship operator was <=>
  • 22
    And I'm like, pretty sure those aren't implemented as individual operators, they're just how order of operations works out, aren't they?
  • 12
    Yeah those are just normal operators with weird spacing, but I like the shape of it!
  • 3
    @theapemachine it is, and the only time I have ever used it was for null safe comparisons in MySQL.

    These operators, will probably never be used in a everyday project unless you’re a crazy, sadistic bastard who enjoys making other people’s life difficult or you actually have a genuine use case for them.
  • 0
    They're just normal operators.
    $x -= -$y

    In math form: x - ( -y ) = x+y
Your Job Suck?
Get a Better Job
Add Comment