single quotes versus double quotes in PHP

single quotes versus double quotes in PHP

Difference between using single quotes versus double quotes to enclose a string. If you need stuff to be interpreted, you use double quotes.

If you need to indicate a literal string.
PHP parses the string in double quotes looking for variables - using more memory while string in single quotes doesn’t parse.

- Single quotes denote a literal string:

<?php
$site = ‘PHP Sript’;
echo ‘I like $site.’;
?>

- Double quotes allow interpolation:

<?php
$site = ‘PHP Script’;
echo “I like $site.”;
?>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.