include with html file

0

Galera I put a file called php.php as follows:

<?php

$nome = "nome";
$idade = "25";
$peso = "78";

include "layout.html";

This file includes the layout.html file, which looks like this:

<table align="center" border="1">
<tr>
    <td>
        Nome
    </td>
    <td>
        Idade
    </td>
    <td>
        Peso
    </td>
</tr>
<tr>
    <td>
        variavel
    </td>
    <td>
        variavel
    </td>
    <td>
        variavel
    </td>
</tr>
</table>

Tomorrow is doubt. How to make php put in the variables inside the html, if I change the html to php.

Does anyone know of any way? I thought about creating a function that would change everything that counted %% inside the html by $. Example:

%% name %% would be exchanged for $ name.

Does anyone have a solution?

    
asked by anonymous 09.05.2016 / 19:41

1 answer

1

Try this:

<table align="center" border="1">
<tr>
    <td>
        Nome
    </td>
    <td>
        Idade
    </td>
    <td>
        Peso
    </td>
</tr>
<tr>
    <td>
        <?php echo $nome; ?>
    </td>
    <td>
        <?php echo $idade; ?>
    </td>
    <td>
        <?php echo $peso; ?>
    </td>
</tr>
</table>
    
09.05.2016 / 19:43