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

Eric Mann eric at eam.me
Thu Mar 3 22:06:17 UTC 2011


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
>


More information about the wp-hackers mailing list