By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,053 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,053 IT Pros & Developers. It's quick & easy.

Both work, but which is best...

P: n/a
Newbie here. Both of these seem to work fine, but is there any reason why
one is better than the other?

$myvar = "cheese";

$biscuits = "I just love $myvar biscuits";
or
$biscuits = "I just love" . $myvar . "biscuits";

print($biscuits);
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
mike wrote:
Newbie here. Both of these seem to work fine, but is there any reason why
one is better than the other?

$myvar = "cheese";

$biscuits = "I just love $myvar biscuits";
or
$biscuits = "I just love" . $myvar . "biscuits";

print($biscuits);


They're not exactly equal (*) ...
Just use the one you like the best.
The difference isn't noticeable.

.... you missed one other way to do it:

$biscuits = 'I just love ' . $myvar . ' biscuits';
The differences in speed between all of these are nothing compared to
how easy/hard you'll find understanding and changing the code later.
(*)
first ==> I just love cheese biscuits
second ==> I just lovecheesebiscuits

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.