Single or doble quotation marks
When you write the code <?php echo "Hello World!"; ?> or <?php echo 'Hello World!'; ?> Why Alena Holligan used single quotation marks? or Can you use doble quotation marks? any difference.
Jennifer NordellTreehouse Staff
Hi Oscar! In this case, yes, you could use either single or double quotes. Either work for this example. The biggest difference is when you have a string containing a variable name in it. Let me show you an example and feel free to run this in a workspace!
<?php $hello = "Hello World!"; echo "$hello"; echo '$hello'; ?>
If/when you run this code the first echo will actually echo out "Hello World!". It expands the variable to retrieve the value inside it and display the value. The single quotes don't do that. They simply echo out the variable name. So the second echo will echo out
She could have used either here and achieved the same results. But she had to choose one, and the single quotes is what she chose for this example. Hope this helps!