Single and Double Quotes

Ever wonder what’s the difference between ” ” vs. ‘ ‘ ? Surprisingly there is one and it’s actually deceptively simple. The basic definition of single quotes is verbatim or WYSIWYG. In contrast, double quotes have a built in logic and can recognize variables. So here’s a visual

<?php
$number = 303;
echo '$number is my favorite number'
?>

will output: $number is my favorite number. However the opposite is true for double quotes

<?php
$number = 303;
echo "$number is my favorite number"
?>

output: 303 is my favorite number







Leave a Reply



blog