What is the result of $x = ’10’ + 5 + ‘2.5’; echo gettype($x);?

PHP Intermediate Hard

PHP Intermediate — Hard

What is the result of $x = ’10’ + 5 + ‘2.5’; echo gettype($x);?

Key points

  • Arithmetic operations trigger type juggling.
  • Presence of a decimal in numeric strings forces float conversion.
  • PHP's 'float' type is internally represented as a double.

Ready to go further?

Related questions