|
Posted by Paul Lautman on July 4, 2008, 12:11 pm
Please log in for more thread options Twayne wrote:
> Hi,
>
> Irrelevant question time, probably:
>
> Is there any advantage/reason to use one format over the other for the
> following two types of echo statements?
>
> 1. echo "error is " . $error;
> 2. echo "error is $error";
>
> Obviously I'm talking about longer statements than the samples above,
> but they do create identical outputs.
>
> Line 1 is how most of the code snippets/samples I find are written.
> But line 2 is a lot less typing and for me at least, easier to keep
> track of.
>
> Maybe it's my gross inexperience showing but the only time I see the
> ..." . concatenator useful is if I want to print something like
> "$error is 0"; then it's just echo '$error is ' . $error; but as
> always, there are still other ways to accomplish it, which I didn't
> mean to get into here.
>
> If you consider this a waste of your time, OK; I understand. But if
> have an opinion I'd be interested to hear whether there is any
> advantage of one over the other. Mostly, so that I pick up the
> preferred habit if nothing else.
>
> TIA,
>
> Twayne
Rather than
2. echo "error is $error";
you should get used to using:
2. echo "error is ";
And
1. echo "error is " . $error;
is better as:
1. echo 'error is ' . $error;
|