php - Why is '...' concatenating two numbers in my code? -


i have following code snippet don't understand output:

echo 20...7; 

why code output 200.7?

from know ... splat operator, called in ruby, lets have function variable number of arguments, don't understand here in context echo.

can explain code does?

no not splat/unpacking operator, thought might seem is. result of php parsing process. writing code bit different might clear confusion:

echo  20.           .           .7; #       ↑           ↑           ↑ #    decimal  concatenation  decimal #      dot         dot         dot 

now have know .7 0.7 , can omit 0 in php described in syntax float numbers:

dnum          ([0-9]*[\.]{lnum}) | ({lnum}[\.][0-9]*) 

so php concatenates 2 numbers , while doing php's type juggling silently convert both numbers strings.

so in end code equivalent to:

echo "20" . "0.7"; //output: "200.7" 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -