0

I am sorry if this is duplicated but I could not find an 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>"; 
}
Mat5hias
  • 62
  • 9

2 Answers2

5

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'>";
Barmar
  • 741,623
  • 53
  • 500
  • 612
1
<?php if (isset($ioTitle)){
        echo "<div style='background-color:". $params->get('colorbgt').";' class=\"ioTitleBox\"><h3 class=\"ioTitle\">";
        echo $params->get("ioTitle"); echo "</h3></div>"; 
                    }

Is this how you want it?

You are echo-ing from inside an echo, you just need to concatenate that part into the existing echo statement.

coderodour
  • 1,072
  • 8
  • 16