PDA

View Full Version : Which version of this statement is preferred?


vindaloo
07-14-2003, 08:34 AM
Hi,

I've seen the following statement in a PHP tutorial:
echo "<H1>Error:".$error."</H1>";
However, the PHP manual suggests using a simpler form without the concatenation, as in:
echo "<H1>Error:$error</H1>";
They both give the same result here, but can there ever be an advantage of using one over the other, or is it just personal preference?

Thanks,
Vindaloo

vindaloo
07-15-2003, 01:42 AM
Thanks again David,

This answers the question perfectly. From other programming languages, I'm used to the rule that variables must be placed outside of quotes, as in the first example I gave. However, I think I'll prefer using the style of the second example as it keeps things a lot tidier when combining a few variables into one statement.

Regards, Vindaloo