Can I echo in single quotes with a variable?
example
echo 'I love my $variable.';
I need to do this because I have lots of HTML to echo too.
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!
No. '
will not parse variables. use
echo 'I love my '.$variable.'.';
or
echo "I love my {$variable}. And I have \" some characters escaped";
If there's a lot of text, have a look at the Heredoc syntax.
$var = <<<EOT
<div style="">Some 'text' {$variable}</div>
EOT;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With