<html>
<body>
<h1>Listagem de Produtos</h1>
<table>
<?php foreach($produtos as $p): ?>
<tr>
<td><?=$p->nome;?></td>
<td><?=$p->valor;?></td>
<td><?=$p->descricao;?></td>
<td><?=$p->valor;?></td>
</tr>
<?php endforeach; ?>
</table>
</body>
</html>
Try the above code. The code was missing :
at $p)
.
I simplified his $p->valor
.
To display a result of a variable on the screen you should use PHP echo
or print
.
The simplification made in your code was the printing of the value in the column of table <?=$variavel;?>
displays the value of the direct variable on the screen.
More information about foreach in the PHP documentation