NYCPHP Meetup

NYPHP.org

[nycphp-talk] single quote vs. double quote

tedd tedd at sperling.com
Tue Apr 3 08:43:14 EDT 2007


At 9:12 AM +0530 4/3/07, 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.

I'm not sure if what you are saying includes this, but I use double 
quotes all the time in php for producing html. For example:

[1] echo("$myResult <br/>");
[2] echo('<a href="mydomain.com/mywidget.php" >$myResult</a>');

The use of double quotes in [1] allows me to print something without 
having to use the dot operator.

The use of the single quotes in [2] allows me to use the double 
quotes in html without having to escape them.

Note in both usages, the variable $myResult was used without regard to quotes.

Cheers,

tedd
-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the talk mailing list