[wp-hackers] usage of single quotes and double quotes in PHP

Dion Hulse (dd32) wordpress at dd32.id.au
Thu Mar 3 22:22:58 UTC 2011


In WordPress, ' > " unless the string is going to contain ' itself (cleaner
to avoid the escaping of ')
We're not too strict on it though, a patch isn't going to be rejected
because of it, nor is it really something that's worth a huge patch changing
it everywhere.

On 4 March 2011 09:06, Eric Mann <eric at eam.me> wrote:

> According to the PHP manual[1]:
>
> Parsing variables within strings uses more memory than string
> concatenation.
> > When writing a PHP script in which memory usage is a concern, consider
> using
> > the concatenation operator (.) rather than variable parsing.
>
>
> So ... echo "This is a $var"; would be more demanding on the server than
> echo 'This is a ' . $var;
>
>  [1]: http://ca.php.net/types.string
>
> On Thu, Mar 3, 2011 at 1:43 PM, Satish Gandham <satish.iitg at gmail.com
> >wrote:
>
> > *We use single quotes when we are not evaluating anything within the*
> > *string.
> > **
> > **echo "Hello World!" uses more cpu resources than echo 'Hello World'.
> > *
> > I* want know which of these two is better.
> > *
> > * <?php
> > ** echo "This is a string with variable $test_variable"
> > ** ?>
> > **
> > **  <?php
> > **   echo 'This is another variant of the above statement
> '.$test_variable
> > **  ?>
> >
> >
> > Regards
> > Satish Gandham
> > *
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list