Is it necessary to initialize / declare a variable before a loop or a function?
Whether I initialize / declare variable before or not my code still works.
I'm sharing demo code for what I actually mean:
$cars = null;
foreach ($build as $brand) {
$cars .= $brand . ",";
}
echo $cars;
Or
foreach ($build as $brand) {
$cars .= $brand . ",";
}
echo $cars;
Both pieces of code works same for me, so is it necessary to initialize / declare a variable at the beginning?