PHP Concatenation with DomPDF

0

Talk about beauty? The problem is that when I try to put the $ _POST method to show the contents of a dynamic form, it presents me with a error:

  Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\Emp\gerar_pdf.php on line 176

The next line of this error is this:

  $html .="<td>$_POST['interrupcao'][$i]</td>";

Here's a snippet of what I'm trying to show:

  $html .= "<table>";
  $html .= "<tr>";
  $html .= "<th>INTERRUPÇÕES</th>";
  $html .= "<th>Início</th>";
  $html .= "<th>Término</th>";
  $html .= "</tr>";
  $teste = $_POST['interrupcao'];
   for ($i=0; $i < count($teste); $i++) {
  $html .="<td>$_POST['interrupcao'][$i]</td>";
  $html .="<td>$_POST['inicioint'][$i]</td>";
  $html .="<td>$_POST['terminoint'][$i]</td>";
   }    
  $html .= "<tr>";
  $html .= "</tr>";
  $html .= "</table>";
    
asked by anonymous 08.11.2017 / 13:26

1 answer

0

You should protect variables with quotation marks using braces:

 $html .="<td>{$_POST['interrupcao'][$i]}</td>";
 $html .="<td>{$_POST['inicioint'][$i]}</td>";
 $html .="<td>{$_POST['terminoint'][$i]}</td>";

Passing your code through 3v4l: link

    
08.11.2017 / 13:35