Re: Variable as an index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



True, it might mean the very slightest in milliseconds...depending on what
you're doing/hardware. However, no harm in understanding the difference/how
it works.
Many will code echo "Hello World" and echo 'Hello World'; and never know the
difference, I just happen to think being aware of the details will help for
the long term programmer.
Since, I brought it up, I'll go ahead and give another example. Ternaries
that make a lot of people feel awesome because a lot is being accomplished
in one line are also more opcodes than their if-else statement
equivalents...and often times can be more confusing to future maintainers of
the code.

Anthony Gentile



On Sun, Dec 21, 2008 at 6:20 PM, Chris <dmagick@xxxxxxxxx> wrote:

> Anthony Gentile wrote:
>
>> for e.g.
>> $var = 'world';
>> echo "hello $var";
>> vs
>> echo 'hello '.$var;
>>
>> The first uses twice as many opcodes as compared to the second. The first
>> is
>> init a string and adding to it the first part(string) and then the second
>> part (var); once completed it can echo it out. The second is simply two
>> opcodes, a concatenate and an echo. Interpolation.
>>
>
> I'd call this a micro-optimization. If changing this causes that much of a
> difference in your script, wow - you're way ahead of the rest of us.
>
>
> http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html
>
> http://www.phpbench.com/
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux