Bird
0
0

Which PHP function can be used to check the type of a variable and returns a string like "integer" or "string"?

easy📝 Conceptual Q2 of 15
PHP - Type Handling
Which PHP function can be used to check the type of a variable and returns a string like "integer" or "string"?
Atypeof()
Btypecheck()
Cvar_type()
Dgettype()
Step-by-Step Solution
Solution:
  1. Step 1: Recall PHP functions for type checking

    PHP does not have a typeof() function; gettype() is the correct built-in function that returns the type as a string.
  2. Step 2: Verify options

    Only gettype() is a valid PHP function that returns the variable type as a string.
  3. Final Answer:

    gettype() -> Option D
  4. Quick Check:

    gettype() = returns type string [OK]
Quick Trick: Use gettype() in PHP, not typeof() like JavaScript [OK]
Common Mistakes:
  • Using typeof() which is not PHP
  • Assuming typecheck() exists
  • Confusing with var_dump() output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes