What is the result of the expression $a = ‘5’ + 2; echo gettype($a);?

PHP Intermediate Medium

PHP Intermediate — Medium

What is the result of the expression $a = ‘5’ + 2; echo gettype($a);?

Key points

  • Arithmetic operators trigger type juggling
  • Numeric strings are converted to numeric types
  • The result of integer addition is an integer

Ready to go further?

Related questions