RE: [PHP] Are '...' faster than "..." in normal code? Single Quot es vs. Double Quotes
| From: | Dave VanAuken | Date: | Mon, 04 Dec 2000 23:38:00 +0000 |
| Subject: | RE: [PHP] Are '...' faster than "..." in normal code? Single Quot es vs. Double Quotes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28666@lists.php.net to get a copy of this message | ||
I suspect this thread will get roasted soon...
I use double quotes all the time... call it lazy (or just not wanting to
hunt down a single that should have been a double and vice versa) but I can
not see how there would be a significant gain from not having PHP parse a
line to check for variables. Under normal usage you are either parsing it
anyway because you are building a table or have output that is littered with
PHP variable output, or you would be best off exiting the PHP tag and
starting it up again once you were done with your non PHP parsed 1000 word
requium.
instead of
echo '';
use
?><?
save yourself 3 whole bytes... do that a couple thousand times in a single
file and you might see a difference.
interesting question, mute point IMO since we are likely talking
milliseconds of difference... its like trying to figure our if your typing
appears on the screen faster on a 650mhz cpu or a 700mhz :)
Dave
-----Original Message-----
From: Matthew M. Boulter [mailto:cmdmatb@iprimus.com.au]
Sent: Monday, December 04, 2000 6:11 PM
To: php-general@lists.php.net
I wasn't asking or talking about interpolation, mine is a general query:
For all other strings, where I'm NOT doing any interpolation, I'm getting
the impression that ' ' is faster than " ".
Cool, seems logical.
So why doesn't everyone use it? How come everyone's code is scattered with
array indexes as ["baz"] and default values like
var $myProperty = "default_val";
am I being too pedantic by thinking to myself (d'oh have to use a quotation
mark, grrrr) "I'm not doing anything here with the string other than
just wanting it's value, so I'll use single quotes".
Where as those times where I'll interpolate or I want \n, etc correctly used
I'll use "double quotes".
And okay since we're burning lets add some accelerant:
What's better/faster?
$bootType = 'Army'; // or should that be $bootType = "Army" ;)
echo "Yo momma wears $bootType boots";
or
echo 'Yo momma wears '.$bootType.' boots';
or
// this one seems silly
echo "Yo momma wears ".$bootType." boots";
Feel the fires, taste the death. hehehe... 8-)
Matt.