Bird
0
0

In PHP, which of the following values is considered false when converted to a boolean?

easy📝 Conceptual Q1 of 15
PHP - Variables and Data Types
In PHP, which of the following values is considered false when converted to a boolean?
AAn empty string ""
BThe string "false"
CThe integer 1
DA non-empty array
Step-by-Step Solution
Solution:
  1. Step 1: Understand PHP boolean conversion rules

    PHP treats certain values as false when converted to boolean, including empty strings, 0, null, and empty arrays.
  2. Step 2: Analyze each option

    "" (empty string) is false; "false" (non-empty string) is true; integer 1 is true; non-empty array is true.
  3. Final Answer:

    An empty string "" is false in boolean context. -> Option A
  4. Quick Check:

    Empty string = false [OK]
Quick Trick: Empty string is false, non-empty string is true [OK]
Common Mistakes:
  • Thinking string "false" is false
  • Confusing empty string with string "0"
  • Assuming non-empty arrays are false

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes