Re: Re: Any difference between these 2 forms of syntax?

From: Date: Sat, 11 May 2002 02:48:29 +0000
Subject: Re: Re: Any difference between these 2 forms of syntax?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-97061@lists.php.net to get a copy of this message
On Fri, 10 May 2002, Austin Marshall wrote: >> I wonder if it matters from an overhead point of view, is PHP doing >> more work than it ought to using " instead of ' because it's expecting >> variables? > > I'd be interested to see if there were much a difference > performance-wise though. Quick-and-dirty speed test (comments on my methodology are welcome): <? $z = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => 4); list ($msec, $sec) = explode(' ', microtime()); $start_time = $msec + $sec; $total = 0; for ($i = 0; $i < 100000; $i++) $total += $z["three"]; list ($msec, $sec) = explode(' ', microtime()); printf ('Elapsed: %f seconds.', ($msec + $sec) - $start_time); ?> I ran it this way and then changed the $total += line to use 'single quotes' instead of "double". There was no noticeable difference in times; the variation from one run to the next (between 0.33 and 0.35 seconds) was far greater than the variation between quote types. Nevertheless I find myself irresistably compelled to keep using the single quotes when I know no string variable substitution is required. Call me an irrational old fool. miguel

« previous php.general (#97061) next »