NYCPHP Meetup

NYPHP.org

[nycphp-talk] single quote vs. double quote

David Krings ramons at gmx.net
Wed Apr 11 06:37:08 EDT 2007


Anirudh Zala wrote:
> To me 2nd effect of "bad practicing" is 
> more important as far as coding is concerned.
> 
> Even if there is little time-difference, this also tells that one is using 
> inappropriate ways while coding. So this issue has impact from both sides. To 
> me it is against good practice. To some extent it is quite fine but when 
> people "double quote" paragraph of 100 lines containing static data, it would 
> be called as bad practice.
> 

I agree, I thought for some time on how to optimize my code and I am 
pretty sure there are things that give me a bigger bang for the buck 
than changing double quotes to single quotes.
I further think that there is a balance between code performance and 
readability. I've seen code where the programmer drops out of PHP for 
even a single word instead of concatenating that into the echoed string. 
  That is plain silly and I doubt that this turns into a performance 
improvement at all compared to doing that for the before mentioned 100 
lines of static text. But even for that there is maybe an explanation. 
The first thing for PHP that I learned was this:
print("Hello World!");
It took me about a year to make the move to the much easier echo and 
much later I learned that I can drop out of PHP into plain HTML and then 
go back. Bad practices are typically coming from bad teaching, and 
especially the PHP manual on php.net makes excessive use of double 
quotes. No wonder only a few really understand what the difference is, 
what to use when and why.

David



More information about the talk mailing list