You get an undefined variable because you combine the value of yourself with another value.
Equivalent
$str = $str . "something";
Thus, he cannot say what the initial meaning is. This is equivalent to this:
$str = [undefined value] . "something";
What is the result of concatenating [undefined value] and "something" ? The interpreter cannot say ...
So, you must first put the "" in the variable to initialize the value of the variable, just like you.
NTN
vIceBerg
source share