Mat5hias Mat5hias - 2 months ago 8
CSS Question

Escape the double quotes in css inline style in php echo

Iam sorry if this is duplicated but i could not find a answer to this situation. I am trying to escape the double quotes from the inline style in the php code.

<?php if (isset($ioTitle)){
echo "<div style='background-color: echo $params->get('colorbgt'); ;' class=\"ioTitleBox\"><h3 class=\"ioTitle\">";
echo $params->get("ioTitle"); echo "</h3></div>";


You can't put echo inside a string and expect it to be executed. You need to use concatenation.

echo "<div style='background-color: " . $params->get('colorbgt') . ";' class=\"ioTitleBox\"><h3 class=\"ioTitle\">";

You don't need to escape anything in the style for this. Also, you can use single quotes around the classes, to avoid those escapes.

echo "<div style='background-color: " . $params->get('colorbgt') . ";' class='ioTitleBox'><h3 class='ioTitle'>";