When I want to stringify a variable: does it make a difference whether I put the variable in double quotation marks
$string = "$v";
or whether I concatenate the variable with an empty string
$string = '' . $v;
?
When I want to stringify a variable: does it make a difference whether I put the variable in double quotation marks
$string = "$v";
or whether I concatenate the variable with an empty string
$string = '' . $v;
?
So never? Operators that expect a string will stringify their operands. It's super rare that one needs to stringify explicitly. I think I've only ever done this once.
The code generated code is different.
This difference will matter for objects with overloaded operators, which is one of the few times you might want to explicitly stringify.
It will still end up being the same for most classes. You should only have problems with a class for which
.
doesn't mean concatenation.