ahs10 Posted February 26, 2008 Share Posted February 26, 2008 do i have to/should i declare a variable before using .= to add onto it? for example.... $myVar = ''; // is this line necessary? while ($row = mysql_fetch_array($result)) { $myVar .= $row['sqlData']; } Quote Link to comment https://forums.phpfreaks.com/topic/93154--/ Share on other sites More sharing options...
revraz Posted February 26, 2008 Share Posted February 26, 2008 Comment it and see what happens. Quote Link to comment https://forums.phpfreaks.com/topic/93154--/#findComment-477248 Share on other sites More sharing options...
Lashiec Posted February 26, 2008 Share Posted February 26, 2008 You'll get a notice that $myVar isn't defined if you try to $myVar .= "whatever"; without doing something like $myVar = null;. It still should work, but coding so you don't get notices is better. If you have all warning/notices turned on that is. Quote Link to comment https://forums.phpfreaks.com/topic/93154--/#findComment-477256 Share on other sites More sharing options...
ahs10 Posted February 26, 2008 Author Share Posted February 26, 2008 thank you lashiec. i'm gonna jump on box right quick too. don't reply to a post and tell someone to try it to see if it works, that defeats one purpose of a message board, a storage unit of problems and answers. this instance in particular, "trying it to see if it works" wouldn't have answered my question.... "do i have to/SHOULD I....." as explained by lashiec's answer. thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/93154--/#findComment-477262 Share on other sites More sharing options...
revraz Posted February 26, 2008 Share Posted February 26, 2008 Or don't ask a question that you can simply just try and see the results for yourself. don't reply to a post and tell someone to try it to see if it works, that defeats one purpose of a message board, a storage unit of problems and answers. this instance in particular, "trying it to see if it works" wouldn't have answered my question.... "do i have to/SHOULD I....." as explained by lashiec's answer. thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/93154--/#findComment-477332 Share on other sites More sharing options...
aebstract Posted February 26, 2008 Share Posted February 26, 2008 Yeah he is kinda right about how you could have easily removed the $myVar = ''; and seen if it worked and what it did, without it there.. Quote Link to comment https://forums.phpfreaks.com/topic/93154--/#findComment-477335 Share on other sites More sharing options...
sasa Posted February 26, 2008 Share Posted February 26, 2008 it's good practis to declare variable before use it Quote Link to comment https://forums.phpfreaks.com/topic/93154--/#findComment-477441 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.