nrg_alpha wrote:When I declare a variable, I tend to make it NULL initially.
As far as possible, declare a variable near first use, where you are able to initialise it with a suitable value instead of blindly initialising it to NULL.
nrg_alpha wrote:Granted, we know that one doesn't really need to even declare the variable in the first place (if I understand correctly, in that case, the variable is created on assignment).
Yes, but if the loop does not iterate even once, the variable would not exist. Furthermore, there is no simple assignment in the loop, but rather only the use of combined concatentation and assignment, hence the variable should exist even before the loop.
nrg_alpha wrote:I suppose the purpose of variable declaration is to give the programmer some coding clarity..
That is also true.
nrg_alpha wrote:Is there any actual difference between declaring a variable as say '' vs NULL initially?
Since you are dealing with a string, why not initialise it to an empty string instead of NULL? There is an "actual difference" in that say, isset and is_null() will return different values when the string is set to '' and when it is set to NULL, but I think that that is not a practical concern in this case.