View Single Post
Old 04-13-2011, 04:30 PM   PM User | #14
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
The tests do indicate that any double quoted text is still slower than single quoted text, but that is to be expected. There is really no way to get around this, as long as PHP persists in expanding double quoted strings, it will always take more cycles to process. Personally, I'd prefer that PHP took double quotations as straight strings (non-expanded, though still continue to expand escaped chars), and single quotations as chars only, but that would also never happen (PHP is a string based language, it doesn't really have the concept of just a char, which of course is the exact opposite of its C driven engine which has no string).
The difference of course being that machines are much more powerful nowadays than they were 10, and even 5 years ago, and really don't need to worry about this; is saving 3 - 30 nano-seconds of processing really worthwhile? Nope, definitely not. The most interesting benches there are the last two of the single vs double tests. I'm a little surprised that \$ indicates a slower parse than the $ alone, which almost looks like they are evaluating it from the inside out instead of the outside in.

So really, it simply comes down to a personal preference on this; choose one and stick with it. Chances are you'll never need to script PHP on a legacy machine. Mine is to stick with the single quotations (I remember back to my 16MB web server back in the day on a P2 300, optimization really did a lot back then), and so I will continue to recommend the use of single.

One thing to mention about these benches. Some of them need to be taken with a grain of salt. They have a test for $obj = $someClass->f() vs. $obj =& $someClass->f() , but the usage of return by reference isn't acknowledge as the reasoning. If the result is returned by reference, than it must act as a reference. Since they don't mention the PHP version in use, the & should for sure be omitted in PHP5 UNLESS the method itself is slated as a return-by-reference method (ie: public function &f()); the only thing that is always returned by reference in PHP5+ is objects; PHP4 on the other hand would need to act a reference even if the returned result is an object. Otherwise, PHP's copy-on-write techniques make standard non-reference assignments as references useless as there will be no extra consumed memory until the variable has been rewritten (if that makes sense >.<).

That out of the way, as Dormilich mentioned, we do need to see your updated code to determine where the problem now lies.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote