Can I echo a variable with single quotes?

You must either use:

echo 'I love my ' . $variable . '.';

This method appends the variable to the string.

Or you could use:

echo "I love my $variable.";

Notice the double quotes used here!

Leave a Comment