brandonstills |
06-10-2008 09:01 PM |
Quote:
Originally Posted by borked
(Post 14300380)
Also, to give the parser an easier time, add braces around your vars when inside double quotes if you absolutely want to have them inside the double quotes
ie
echo "<td valign='top'><p align='center'><a href='girls/{$rec->dirname}/{$rec->dirname}.html'><img title='{$cat} {$rec->name} Gallery' src='Models/{$rec->dirname}/1.jpg' alt='{$cat} {$rec->name} Gallery' width='150' height='200' border='1' /><br>{$cat} {$rec->name}</a></p></td>";
for parser speed inside/outside quotes, have a look at
http://riyono.com/archives/2004/09/3...p-application/
|
Who cares about giving the parser an easier time? It exists to serve the programmer. I'm tired of all these people bitching about how PHP double quotes are slow. Using single quotes with the '.' operator maybe be faster but ask yourself this. By how much? Ok, even if it is 10 times faster how long do you think that translates to in actual time. Fractions of a nano second. It would have to be deep in an inner loop that is called 100,000+ times before the user would even notice a _slight_ difference. What's more important, having readable code, or shaving an additional 0.000000000001 seconds off the page loading time?
"Premature optimization is the root of all evil."
Now, I'm not one to say you should never optimize. I used to expand assembly code to half a dozen instructions when I could do it with 1 because the MUL instruction used to be really slow on the early x86 platforms. But only inside some kind of loop where it would mean a noticable difference to the user. There's a time and place for optimization but don't make your code more unreadable needlessly.
|