OT - Programming Languages
Tim Streater wrote:
In article , Mike Barnes
wrote:
Tim Watts wrote:
On 31/01/15 04:38, John Rumm wrote:
print "Number "; counter
print "Number " . $counter . "\n";
Can anyone join in?
echo "Number $counter", PHP_EOL;
(has the advantage of an environment-dependent EOL character)
echo 'Number ' . $counter ...
Keeping variables out of strings (and using a single-quoted string) is
better as PHP doesn't have to ferret through the string looking for
special characters. Not that it matters in the example above.
Quite. But for ultimate efficiency some would stress the superiority of
echo 'Number ', $counter
so that the concatenation takes place in the print buffer rather than
during expression evaluation.
But I really like the readability of interpolated variables, and I'll
carry on doing it even if it does make the computer work a tiny tiny bit
harder.
BTW I really hate "echo" when "print" would be more meaningful. It's
true that PHP has a print function, but you can't chain expressions as
in the last example above.
--
Mike Barnes
Cheshire, England
|