NYCPHP Meetup

NYPHP.org

[nycphp-talk] single quote vs. double quote

tedd tedd at sperling.com
Tue Apr 3 09:30:34 EDT 2007


At 8:51 AM -0400 4/3/07, Ken Robinson wrote:
>At 08:43 AM 4/3/2007, tedd wrote:
>
>>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.
>
>How you write number [1] comes down to personal preference. I'd 
>rather write it as:
>
>echo $myResult . '<br/>';
>
>In number [2], I hope you realize that the string '$myResult' will 
>be treated as a static string and will not be evaluated.
>
>Also, since "echo" is a language construct and not a function, the 
>parenthesis are not required.

1. Yeah, you're right. In that example I have to put in those escape 
operators to get it to work correctly. But in my defense, I was 
typing code on the fly -- it was the topic and not the syntax I was 
addressing.

echo("<a href=\"mydomain.com/mywidget.php\" >$myResult</a>");

2. Yes, echo is language construct and not a function, but my 
personal preference is to use the parentheses.  It makes it easier 
for me to read and I know if I want to send it more than one 
parameter, then I can't use parentheses. But, my simplistic approach 
to problems usually finds another way.

Cheers,

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



More information about the talk mailing list