Simple Machines Blogs > Developers' Blog
PHP String Replacement Speed Comparison
SleePy:
--- Quote from: groundup on June 12, 2007, 04:35:57 PM ---
--- Quote from: groundup on June 12, 2007, 04:15:16 PM ---$txt['no_sprintf'] = "My name is $GLOBALS[NAME] and I am a $GLOBALS[JOB] here at $GLOBALS[COMPANY] where I work for $GLOBALS[BOSSTITLE] $GLOBALS[BOSS]";
--- End quote ---
or something similar to that. As for not being defined, okay, I guess there is where you have the difference. Although, %1$s can hardly be considered readable.
--- End quote ---
Still isn't very readable. But I choose speed over readability of the language strings myself ;) I don't care if I can't read them if it makes my forum twice as fast to use it another way I will.
Joshua Dickerson:
If you want speed, language constructs work better. Although, the speed difference between all of these is very little.
Daniel15:
--- Quote ---sprintf() isn't really in the same boat as the other string replacement functions IMO. It is more of a fancy concatenation and in that boat, it isn't so fast.
--- End quote ---
It's not classified as "fancy concatenation"; it's classified as string formatting ;). Still, I agree in a sense - It is a formatting function, not a replacement function :)
And I agree with Thantos' large post above :)
Navigation
[0] Message Index
[*] Previous page
Go to full version