[nycphp-talk] single quote vs. double quote
David Krings
ramons at gmx.net
Tue Apr 3 06:38:05 EDT 2007
Anirudh Zala wrote:
> Please remember below rules while writing PHP expressions.
>
> #1 There is practically NO use of "double quotes" in PHP in writing
> expressions EXCEPT expanding sequences like converting "\n" into newline,
> "\t" to tabulator (in regex etc.). Which means you should not use "double
> quotes" at any other place than above.
>
> #2 When your data is static, use 'single quotes' to tell PHP to use it "as it
> is", if dynamic then should not be enclosed by ANY quote.
>
> #3 If you have mixture of static+dynamic then use $dynamic.'I am static' style
> to concat dynamic and static data.
>
> When you use "double quotes" PHP will try to EXPAND everything which is
> enclosed in "double quotes" which means variables will be expanded, static
> string will be looked for constants first and if not found then will be used
> as it is and then finally expression will be prepared.
>
> Hope these will clear your thoughts about '' vs. "" quotes.
Thank you very much. I'll print it out and pin it to my forehead.
David
More information about the talk
mailing list