0

I'm trying to use a variable inside a table style for php email but I can't make it work, please help

$message .= '<table rules="all" style="background-color: {'$pnlclr1';}" cellpadding="0">';
sonique
  • 4,539
  • 2
  • 30
  • 39
JCprog
  • 85
  • 1
  • 10
  • Try this https://stackoverflow.com/questions/5368890/mixing-a-php-variable-with-a-string-literal – Hoppo Jun 06 '20 at 08:53
  • 1
    From https://www.php.net/manual/en/language.types.string.php: "_Note: Unlike the double-quoted and heredoc syntaxes, variables and escape sequences for special characters will not be expanded when they occur in single quoted strings._" – brombeer Jun 06 '20 at 09:07

2 Answers2

2
$message .= '<table rules="all" style="background-color: '.$pnlclr1.';" cellpadding="0">';

no need of curly braces {}

Shafeeque TP
  • 361
  • 1
  • 16
1

alternatively if you wrap the table tag in double quotes you can reference the variable without the need for concatenation

$message .= "<table rules='all' style='background-color:$pnlclr1' cellpadding='0'>";
Jesse Jut
  • 349
  • 3
  • 5