1. Home
  2. Computer Science MCQs
  3. PHP
  4. In PHP, what does the spaceship operator expression 3 7…

Added 2 Nov 2026

In PHP, what does the spaceship operator expression 3 <=> 7 return?

  1. 1
  2. 0
  3. false
  4. -1 Correct answer

Correct answer

D. -1

14 views

MCQSEXAM

Explanation

returns −1, 0 or 1 when the left side is less than, equal to or greater than the right. It is handy in usort() callbacks: usort($a, fn($x, $y) => $x $y).

Reference

Asked in: NTS, PHP Developer Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is D? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More PHP MCQs

Practise all PHP MCQs

Similar MCQs