Simple Machines Community Forum

General Community => Scripting Help => Topic started by: draker on August 05, 2004, 11:10:24 PM

Title: Curious
Post by: draker on August 05, 2004, 11:10:24 PM
Okay, I've been coding in PHP for a while now - self taught but able to proudce a fairly decent RPG CMS amazingly enough - and I noticed with SMF that the developers instead of using the normal concatenation command of ' . ' you used ','.  I'm just curious, but what's the difference/benefits of one over the other? 
Title: Re: Curious
Post by: Shoeb Omar on August 06, 2004, 03:06:26 AM
I don't know the details, but as I understand it, using ',' is faster...
Title: Re: Curious
Post by: [Unknown] on August 06, 2004, 03:38:22 AM
Ahem. (sorry, I've explained this many a time to many different PHP programmers, and it's kinda long.. gotta clear my throat.)

See, the normal method might be like this:

echo 'a' . 'b' . 'c';

This is, yes, string concatenation.... equivalent to:

$temporary = 'a' . 'b' . 'c';
echo $temporary;

The method employed a lot in SMF is this:

echo 'a', 'b', 'c';

Which is NOT equivalent to:

$temporary = 'a', 'b', 'c';
echo $temporary;

Instead, it's passing three parameters to the echo contruct.  Then, echo handles each and outputs each.  Because SMF always uses an output buffer, this is faster... but it is not concatenation.. rather, just sending the variables separately and more efficiently.

-[Unknown]