Two scripts with the same result:
Example 1:
<?php
...códigos PHP acima...
$tabela = '<table>';
$tabela .= '<tr>';
$tabela .= '<th> Valor1 </th>';
$tabela .= '<th> Valor2 </th>';
$tabela .= '<th> Valor3 </th>';
$tabela .= '</tr>';
$tabela .= '<tr>';
$tabela .= '<td>' . $valor1 . '</td>';
$tabela .= '<td>' . $valor2 . '</td>';
$tabela .= '<td>' . $valor3 . '</td>';
$tabela .= '</tr>';
$tabela .= '</table>';
echo $tabela;
...códigos PHP abaixo...
?>
Example 2:
<?php
...códigos PHP acima...
?>
<table>
<tr>
<th> Valor1 </th>
<th> Valor2 </th>
<th> Valor3 </th>
</tr>
<tr>
<td> <?= $valor1 ?> </td>
<td> <?= $valor2 ?> </td>
<td> <?= $valor3 ?> </td>
</tr>
</table>
<?
...códigos PHP abaixo...
?>
I would like to know if there are, and what would be, the advantages and disadvantages of the examples above.
For example : I think that handling everything in a variable for later printing would take up more memory and processing, as there is concatenation and space in memory (especially if we consider large loops) p>
Point that raised the question:
Overflow error
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36 bytes)