note 93595 added to function.echo
| From: | javier at osu1 dot php dot net | Date: | Thu, 17 Sep 2009 16:39:06 +0000 |
| Subject: | note 93595 added to function.echo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-160798@lists.php.net to get a copy of this message | ||
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."
----
Server IP: 208.69.120.35
Probable Submitter: 200.78.192.156
----
Manual Page -- http://www.php.net/manual/en/function.echo.php
Edit -- https://master.php.net/note/edit/93595
Del: integrated -- https://master.php.net/note/delete/93595/integrated
Del: useless -- https://master.php.net/note/delete/93595/useless
Del: bad code -- https://master.php.net/note/delete/93595/bad+code
Del: spam -- https://master.php.net/note/delete/93595/spam
Del: non-english -- https://master.php.net/note/delete/93595/non-english
Del: in docs -- https://master.php.net/note/delete/93595/in+docs
Del: other reasons-- https://master.php.net/note/delete/93595
Reject -- https://master.php.net/note/reject/93595
Search -- https://master.php.net/manage/user-notes.php