Explain the behaviour of the spaceship operator?

SpaceShip Operator      –       <=>

Train Asked on June 16, 2016 in PHP.
Add Comment
  • 1 Answer(s)
    Best answer

    This operator has been added as a new feature in php7.

    This is used to compare two expressions and out put whether the left side operand is,

    • Lessthan ( Output  -1 )
    • Greaterthan ( Output  1 )
    • Or equal ( Output  0 )

    than right side operand.

    Eg :-

    1 <=> 3;    // -1

    4 <=> 2;    // 1

    4 <=> 4;    // 0

     

     

    Train Answered on June 16, 2016.
    Add Comment

    Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.