Consider following code:

$var = 1 + "-1.3e3";  
echo $var;
What will be the result of the code above?
Explanation
String contains characters '.', 'e', the string will be evaluated as a float. The value is given by the initial portion of the string. The string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero).
$foo = 1 + "-1.3e3";              // $foo is float (-1299)
$foo = 1 + "bob-1.3e3";           // $foo is integer (1)

@markbelinskiy , added explanation and theory! Sorry for a late response

2016 Aug 31, 3:53:26 PM

why so?

2016 Jul 10, 3:53:39 PM

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по PHP
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты