Re: Re: concatenating with "." or ","

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

 



I would guess that using the comma would be faster, as Thiago mentioned.   
It's just a blind dump of what's in those strings and it dumps the values 
in sequence directly to the output.   A concatenation actually involves 
temporary memory space for holding value A and value B then possibly a 
third memory space as a working area of the size strlen(value A) + 
strlen(value B).. possibly extra operations to figure out the strlen() of 
each then create the third memory space, etc, etc..  (actual way PHP 
handles this is unknown to me... just giving a theoretical example).

echo "This", " is a ", "test";   //   blinding dumps each string to output

echo "This " . " is a " . "test";   // Creates a string "This is a test" then 
dumps it to output


But as always, the best way to find out is to create a script to perform the 
operations a couple thousand times each and record the times.

-TG

----- Original Message -----
From: "Thiago Melo de Paula" <thiagomp@xxxxxxxxx>
To: Yeti <yeti@xxxxxxxxxx>
Cc: php-general@xxxxxxxxxxxxx
Date: Mon, 25 Aug 2008 11:07:41 -0300
Subject: Re:  Re: concatenating with "." or ","

> Hello Yeti!
> 
> This is a very good question, because it shows that you're interested in get
> the max from your PHP codes.
> 
> In my research about php optimization, I couldn't find any relevant article
> about this specific issue, but some sites tell us that using commas instead
> periods on echo constructor would be faster.
> I agree with that, because using the concatenation symbol, will cause PHP to
> take steps to process the concatenation.
> But I think (I never did any performances tests on this subject) that the
> gain would be irrelevant on a general site.
> 
> Regards from Brazil.
> 
> Thiago Melo de Paula
> 
> On Mon, Aug 25, 2008 at 10:25 AM, Yeti <yeti@xxxxxxxxxx> wrote:
> 
> > So it is faster to output various strings using the "," instead of "."?
> >
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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