Posted by Michael Fesser on 07/17/07 13:07
..oO(Andy Jeffries)
>On Mon, 16 Jul 2007 10:01:50 +0200, Markus wrote:
>>
>> print 'text '.$var.' more text '.$arr['foo'].' '.$obj->bar.'st time';
>>
>> It is IMO a good habit if somebody does not want to run into the
>> questions discussed above, and there seem to be even performance reasons
>> for it:
>
>Assuming it is slower to use variables within strings/double quotes* -
>it comes down to the argument of developer time/cost versus server/CPU
>cycles cost.
ACK
The typical bottlenecks in a script are usually IO operations, database
stuff or bad algorithms (bubblesort vs. quicksort for example). Printing
out data shouldn't be an issue at all in most cases.
>Personally I find double quotes with embedded variables to be MUCH more
>readable and therefore a 0.1 second difference over a million prints is
>negligible (particularly in comparison to the delay while waiting for the
>DB servers to respond).
Yep. Additionally I often prefer printf/sprintf when there are a lot of
variables or expressions to embed. It's even slower than a plain print
or echo statement, but much more flexible and readable.
Micha
[Back to original message]
|