Why does
"/" . date("Y") + 1 in PHP return 1?
And a similar question, why does date("Y") . "/" . date("Y") + 1 return 2011?
I am quessing it has something to do with operator precedence, because date("Y") . "/" . (date("Y") + 1) does return the expected "2010/2011"
Yep.
.binds more tightly than+, so:is parsed as:
The left side doesn’t start with any numbers, so when you convert it to a number, it becomes 0. Same with the latter:
The left side of the
+starts with 2010 then some non-digits, so when it gets converted to a number, it becomes 2010. Then you add 1.