Bird
0
0

In PHP, what type does the expression '7' * 2 evaluate to?

easy📝 Conceptual Q1 of 15
PHP - Type Handling
In PHP, what type does the expression '7' * 2 evaluate to?
AString
BInteger
CBoolean
DFloat
Step-by-Step Solution
Solution:
  1. Step 1: Understand PHP type coercion in multiplication

    PHP converts string operands to numbers when using arithmetic operators like '*'.
  2. Step 2: Evaluate the expression '7' * 2

    The string '7' is converted to integer 7, then multiplied by 2, resulting in integer 14.
  3. Final Answer:

    Integer -> Option B
  4. Quick Check:

    Type coercion in arithmetic = Integer [OK]
Quick Trick: Strings with numbers convert to int/float in math operations [OK]
Common Mistakes:
  • Thinking result stays string
  • Assuming boolean result
  • Confusing multiplication with concatenation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes