note 93595 deleted from function.echo by danbrown

From: Date: Thu, 17 Sep 2009 16:41:51 +0000
Subject: note 93595 deleted from function.echo by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-160799@lists.php.net to get a copy of this message
Note Submitter: javier ---- i read about this and i wanna share it : print "Hi my name is $a. I am $b"; echo "Hi my name is $a. I am $b"; echo "Hi my name is ".$a.". I am ".$b; echo "Hi my name is ",$a,". I am ",$b; "This might seem weird to you, but the last one is actually the fastest operation. print is slower than echo, putting variables inline in a string is slower than concatenating them, and concatenating strings is slower than using comma-separated echo values! Not only does not-inlining your variables give you a performance boost, but it also makes your code easier to read in any editor that has syntax highlighting (your variables will show up in nice colors). The little-known use of echo as a function that takes a comma-separated list of values is the fastest of them all, since no string operations are performed, it just outputs each parameter. If you combine all this with Tip #1 and use single quotes, you're on your way to some finely-tuned strings."

« previous php.notes (#160799) next »