NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Middle+0 views

What will be the output? ```php $x = 1; if ($x == '1') { echo 'a'; } if ($x == true) { echo 'b'; } if ((bool)$x === true) { echo 'e'; } if ($x === true) { echo 'c'; } if ((int)$x === true) { echo 'd'; } ```

Practice

Asked at

AI answer

abe will be output.

  • $x == '1' is true, so a is output.
  • $x == true is true, so b is output.
  • (bool)$x === true — the type and value match, so e is output.
  • $x === true is false because $x is an integer, not a bool.
  • (int)$x === true is false for the same reason: int is not equal to bool in a strict comparison.

Also asked at AutoSpot

Similar questions