Bird
0
0

Find the mistake in this PHP code:

medium📝 Debug Q7 of 15
PHP - Type Handling
Find the mistake in this PHP code:
$value = "hello";
if (gettype $value == "string") {
echo "It is a string.";
}
AVariable $value is not defined
BWrong comparison operator used
CMissing parentheses in gettype function call
DEcho statement syntax is incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Check gettype() function call syntax

    Functions in PHP require parentheses around arguments, so gettype $value is invalid.
  2. Step 2: Verify other parts

    Comparison operator == is correct, $value is defined, echo syntax is valid.
  3. Final Answer:

    Missing parentheses in gettype function call -> Option C
  4. Quick Check:

    Function calls need parentheses in PHP [OK]
Quick Trick: Always use parentheses when calling functions [OK]
Common Mistakes:
  • Omitting parentheses in function calls
  • Using assignment instead of comparison
  • Undefined variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes