0

I have php string with css code. And I want to add php value to css code ( $main_color ). So I try:

$css = $css . "
    .main{ color:<?php echo esc_attr($main_color);?>; }
";

but it doesnt work.

name name2
  • 123
  • 4
  • 10

1 Answers1

0

You can't nest PHP tags like that; you need to concatenate the values:

$css = $css . "
    .main{ " . esc_attr($main_color) . "; }
";